@novasamatech/host-api 0.5.0-16 → 0.5.0-17
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/features.d.ts +2 -2
- package/dist/interactions/features.js +2 -2
- 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/messageEncoder.d.ts +68 -107
- package/dist/messageEncoder.js +11 -14
- package/package.json +1 -1
package/dist/commonEncoders.d.ts
CHANGED
package/dist/commonEncoders.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { fromHex, toHex } from '@polkadot-api/utils';
|
|
2
|
-
import { Bytes
|
|
2
|
+
import { Bytes } from 'scale-ts';
|
|
3
3
|
import { createTransportEncoder } from './createTransportEncoder.js';
|
|
4
4
|
export const hexCodec = createTransportEncoder({
|
|
5
5
|
codec: Bytes(),
|
|
6
6
|
from: v => toHex(v),
|
|
7
7
|
to: fromHex,
|
|
8
8
|
});
|
|
9
|
-
export function Result(codec) {
|
|
10
|
-
return Enum({
|
|
11
|
-
Ok: codec,
|
|
12
|
-
Err: str,
|
|
13
|
-
});
|
|
14
|
-
}
|
package/dist/createTransport.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { createTransport } from './createTransport.js';
|
|
|
4
4
|
export type { ConnectionStatus, HexString, Logger, Transport, TransportProvider } from './types.js';
|
|
5
5
|
export { createDefaultLogger } from './logger.js';
|
|
6
6
|
export { type InjectedAccountSchema } from './interactions/accounts.js';
|
|
7
|
-
export { type TxPayloadV1 } from './interactions/sign.js';
|
|
7
|
+
export { type SignPayloadRequest, type TxPayloadV1 } from './interactions/sign.js';
|
|
8
8
|
export { signPayloadCodec } from './interactions/sign.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Enum, Option, Struct, Vector, _void, str } from 'scale-ts';
|
|
2
|
+
import { hexCodec } from '../commonEncoders.js';
|
|
2
3
|
import { createTransportEncoder } from '../createTransportEncoder.js';
|
|
3
4
|
const keypairCodec = Enum({
|
|
4
5
|
ed25519: _void,
|
|
@@ -15,7 +16,7 @@ const keypairEncoder = createTransportEncoder({
|
|
|
15
16
|
});
|
|
16
17
|
const injectedAccountCodec = Struct({
|
|
17
18
|
address: str,
|
|
18
|
-
genesisHash: Option(
|
|
19
|
+
genesisHash: Option(hexCodec),
|
|
19
20
|
name: Option(str),
|
|
20
21
|
type: Option(keypairEncoder),
|
|
21
22
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare const supportFeatureRequestV1Encoder: import("scale-ts").Codec<{
|
|
2
2
|
tag: "chain";
|
|
3
3
|
value: {
|
|
4
|
-
|
|
4
|
+
genesisHash: `0x${string}`;
|
|
5
5
|
};
|
|
6
6
|
}>;
|
|
7
7
|
export declare const supportFeatureResponseV1: import("scale-ts").Codec<{
|
|
8
8
|
tag: "chain";
|
|
9
9
|
value: {
|
|
10
|
-
|
|
10
|
+
genesisHash: `0x${string}`;
|
|
11
11
|
result: boolean;
|
|
12
12
|
};
|
|
13
13
|
}>;
|
|
@@ -2,12 +2,12 @@ import { Enum, Struct, bool } from 'scale-ts';
|
|
|
2
2
|
import { hexCodec } from '../commonEncoders.js';
|
|
3
3
|
export const supportFeatureRequestV1Encoder = Enum({
|
|
4
4
|
chain: Struct({
|
|
5
|
-
|
|
5
|
+
genesisHash: hexCodec,
|
|
6
6
|
}),
|
|
7
7
|
});
|
|
8
8
|
export const supportFeatureResponseV1 = Enum({
|
|
9
9
|
chain: Struct({
|
|
10
|
-
|
|
10
|
+
genesisHash: hexCodec,
|
|
11
11
|
result: bool,
|
|
12
12
|
}),
|
|
13
13
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const papiProviderSendMessageV1Encoder: import("scale-ts").Codec<{
|
|
2
|
-
|
|
2
|
+
genesisHash: `0x${string}`;
|
|
3
3
|
message: string;
|
|
4
4
|
}>;
|
|
5
5
|
export declare const papiProviderReceiveMessageV1Encoder: import("scale-ts").Codec<{
|
|
6
|
-
|
|
6
|
+
genesisHash: `0x${string}`;
|
|
7
7
|
message: string;
|
|
8
8
|
}>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Struct, str } from 'scale-ts';
|
|
2
|
+
import { hexCodec } from '../commonEncoders.js';
|
|
2
3
|
export const papiProviderSendMessageV1Encoder = Struct({
|
|
3
|
-
|
|
4
|
+
genesisHash: hexCodec,
|
|
4
5
|
message: str,
|
|
5
6
|
});
|
|
6
7
|
export const papiProviderReceiveMessageV1Encoder = Struct({
|
|
7
|
-
|
|
8
|
+
genesisHash: hexCodec,
|
|
8
9
|
message: str,
|
|
9
10
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SignerPayloadRaw, SignerResult } from '@polkadot/types/types';
|
|
2
2
|
import type { CodecType } from 'scale-ts';
|
|
3
3
|
import type { HexString } from '../types.js';
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ export declare const signRawRequestV1Encoder: import("scale-ts").Codec<SignerPay
|
|
|
9
9
|
/**
|
|
10
10
|
* @see {import('@polkadot/types/types').SignerPayloadJSON}
|
|
11
11
|
*/
|
|
12
|
-
export type
|
|
12
|
+
export type SignPayloadRequest = CodecType<typeof signPayloadRequestV1Encoder>;
|
|
13
13
|
export declare const signPayloadCodec: import("scale-ts").Codec<{
|
|
14
14
|
address: string;
|
|
15
15
|
blockHash: `0x${string}`;
|
|
@@ -28,7 +28,24 @@ export declare const signPayloadCodec: import("scale-ts").Codec<{
|
|
|
28
28
|
mode: number | undefined;
|
|
29
29
|
withSignedTransaction: boolean | undefined;
|
|
30
30
|
}>;
|
|
31
|
-
export declare const signPayloadRequestV1Encoder: import("scale-ts").Codec<
|
|
31
|
+
export declare const signPayloadRequestV1Encoder: import("scale-ts").Codec<{
|
|
32
|
+
address: string;
|
|
33
|
+
blockHash: `0x${string}`;
|
|
34
|
+
blockNumber: `0x${string}`;
|
|
35
|
+
era: `0x${string}`;
|
|
36
|
+
genesisHash: `0x${string}`;
|
|
37
|
+
method: string;
|
|
38
|
+
nonce: `0x${string}`;
|
|
39
|
+
specVersion: `0x${string}`;
|
|
40
|
+
tip: `0x${string}`;
|
|
41
|
+
transactionVersion: `0x${string}`;
|
|
42
|
+
signedExtensions: string[];
|
|
43
|
+
version: number;
|
|
44
|
+
assetId: `0x${string}` | undefined;
|
|
45
|
+
metadataHash: `0x${string}` | undefined;
|
|
46
|
+
mode: number | undefined;
|
|
47
|
+
withSignedTransaction: boolean | undefined;
|
|
48
|
+
}>;
|
|
32
49
|
export declare const signResponseV1Encoder: import("scale-ts").Codec<SignerResult>;
|
|
33
50
|
/**
|
|
34
51
|
* createTransaction implementation
|
|
@@ -47,48 +47,7 @@ export const signPayloadCodec = Struct({
|
|
|
47
47
|
mode: Option(u32),
|
|
48
48
|
withSignedTransaction: Option(bool),
|
|
49
49
|
});
|
|
50
|
-
export const signPayloadRequestV1Encoder =
|
|
51
|
-
codec: signPayloadCodec,
|
|
52
|
-
from(decoded) {
|
|
53
|
-
return {
|
|
54
|
-
address: decoded.address,
|
|
55
|
-
assetId: decoded.assetId,
|
|
56
|
-
blockHash: decoded.blockHash,
|
|
57
|
-
blockNumber: decoded.blockNumber,
|
|
58
|
-
era: decoded.era,
|
|
59
|
-
genesisHash: decoded.genesisHash,
|
|
60
|
-
method: decoded.method,
|
|
61
|
-
mode: decoded.mode,
|
|
62
|
-
nonce: decoded.nonce,
|
|
63
|
-
specVersion: decoded.specVersion,
|
|
64
|
-
tip: decoded.tip,
|
|
65
|
-
transactionVersion: decoded.transactionVersion,
|
|
66
|
-
signedExtensions: decoded.signedExtensions,
|
|
67
|
-
version: decoded.version,
|
|
68
|
-
withSignedTransaction: decoded.withSignedTransaction,
|
|
69
|
-
};
|
|
70
|
-
},
|
|
71
|
-
to(value) {
|
|
72
|
-
return {
|
|
73
|
-
address: value.address,
|
|
74
|
-
assetId: value.assetId,
|
|
75
|
-
blockHash: value.blockHash,
|
|
76
|
-
blockNumber: value.blockNumber,
|
|
77
|
-
era: value.era,
|
|
78
|
-
genesisHash: value.genesisHash,
|
|
79
|
-
metadataHash: value.metadataHash,
|
|
80
|
-
method: value.method,
|
|
81
|
-
mode: value.mode,
|
|
82
|
-
nonce: value.nonce,
|
|
83
|
-
specVersion: value.specVersion,
|
|
84
|
-
tip: value.tip,
|
|
85
|
-
transactionVersion: value.transactionVersion,
|
|
86
|
-
signedExtensions: value.signedExtensions,
|
|
87
|
-
version: value.version,
|
|
88
|
-
withSignedTransaction: value.withSignedTransaction,
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
});
|
|
50
|
+
export const signPayloadRequestV1Encoder = signPayloadCodec;
|
|
92
51
|
const signResult = Struct({
|
|
93
52
|
id: u32,
|
|
94
53
|
signature: hexCodec,
|
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