@novasamatech/host-api 0.8.2 → 0.8.3
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/protocol/impl.d.ts
CHANGED
|
@@ -858,10 +858,15 @@ export declare const hostApiProtocol: {
|
|
|
858
858
|
} | {
|
|
859
859
|
tag: "PrivateKey";
|
|
860
860
|
value: Uint8Array<ArrayBufferLike>;
|
|
861
|
+
} | {
|
|
862
|
+
tag: "Coins";
|
|
863
|
+
value: Uint8Array<ArrayBufferLike>[];
|
|
861
864
|
};
|
|
862
865
|
}>, Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
|
|
863
866
|
reason: string;
|
|
864
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
867
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
868
|
+
credited: bigint;
|
|
869
|
+
}, "PaymentTopUpErr::PartialPayment">>>];
|
|
865
870
|
}>;
|
|
866
871
|
readonly host_payment_request: VersionedProtocolRequest<{
|
|
867
872
|
readonly v1: [Codec<{
|
|
@@ -911,12 +911,17 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
911
911
|
} | {
|
|
912
912
|
tag: "PrivateKey";
|
|
913
913
|
value: Uint8Array<ArrayBufferLike>;
|
|
914
|
+
} | {
|
|
915
|
+
tag: "Coins";
|
|
916
|
+
value: Uint8Array<ArrayBufferLike>[];
|
|
914
917
|
};
|
|
915
918
|
}>;
|
|
916
919
|
}>> & Record<"host_payment_top_up_response", EnumCodec<{
|
|
917
920
|
readonly v1: Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
|
|
918
921
|
reason: string;
|
|
919
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
922
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
923
|
+
credited: bigint;
|
|
924
|
+
}, "PaymentTopUpErr::PartialPayment">>>;
|
|
920
925
|
}>> & Record<"host_payment_request_request", EnumCodec<{
|
|
921
926
|
readonly v1: Codec<{
|
|
922
927
|
from: number | undefined;
|
|
@@ -2405,6 +2410,9 @@ export declare const Message: Codec<{
|
|
|
2405
2410
|
} | {
|
|
2406
2411
|
tag: "PrivateKey";
|
|
2407
2412
|
value: Uint8Array<ArrayBufferLike>;
|
|
2413
|
+
} | {
|
|
2414
|
+
tag: "Coins";
|
|
2415
|
+
value: Uint8Array<ArrayBufferLike>[];
|
|
2408
2416
|
};
|
|
2409
2417
|
};
|
|
2410
2418
|
};
|
|
@@ -2414,7 +2422,9 @@ export declare const Message: Codec<{
|
|
|
2414
2422
|
tag: "v1";
|
|
2415
2423
|
value: import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
|
|
2416
2424
|
reason: string;
|
|
2417
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
2425
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
2426
|
+
credited: bigint;
|
|
2427
|
+
}, "PaymentTopUpErr::PartialPayment">>;
|
|
2418
2428
|
};
|
|
2419
2429
|
} | {
|
|
2420
2430
|
tag: "host_payment_request_request";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const Ed25519PrivateKey: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
2
|
+
export declare const Sr25519SecretKey: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
2
3
|
export declare const PaymentId: import("scale-ts").Codec<string>;
|
|
3
4
|
export declare const CoinPaymentPurseId: import("scale-ts").Codec<number>;
|
|
4
5
|
export declare const PaymentTopUpSource: import("scale-ts").Codec<{
|
|
@@ -7,6 +8,9 @@ export declare const PaymentTopUpSource: import("scale-ts").Codec<{
|
|
|
7
8
|
} | {
|
|
8
9
|
tag: "PrivateKey";
|
|
9
10
|
value: Uint8Array<ArrayBufferLike>;
|
|
11
|
+
} | {
|
|
12
|
+
tag: "Coins";
|
|
13
|
+
value: Uint8Array<ArrayBufferLike>[];
|
|
10
14
|
}>;
|
|
11
15
|
export declare const PaymentBalance: import("scale-ts").Codec<{
|
|
12
16
|
available: bigint;
|
|
@@ -45,27 +49,43 @@ export declare const PaymentBalanceErr: [import("scale-ts").Encoder<import("@nov
|
|
|
45
49
|
reason: string;
|
|
46
50
|
}, "PaymentBalanceErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentBalanceErr::PermissionDenied">;
|
|
47
51
|
};
|
|
52
|
+
export declare const PartialPaymentErr: import("scale-ts").Codec<{
|
|
53
|
+
credited: bigint;
|
|
54
|
+
}>;
|
|
48
55
|
export declare const PaymentTopUpErr: [import("scale-ts").Encoder<import("@novasamatech/scale").CodecError<{
|
|
49
56
|
reason: string;
|
|
50
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
57
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
58
|
+
credited: bigint;
|
|
59
|
+
}, "PaymentTopUpErr::PartialPayment">>, import("scale-ts").Decoder<import("@novasamatech/scale").CodecError<{
|
|
51
60
|
reason: string;
|
|
52
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
61
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
62
|
+
credited: bigint;
|
|
63
|
+
}, "PaymentTopUpErr::PartialPayment">>] & {
|
|
53
64
|
enc: import("scale-ts").Encoder<import("@novasamatech/scale").CodecError<{
|
|
54
65
|
reason: string;
|
|
55
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
66
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
67
|
+
credited: bigint;
|
|
68
|
+
}, "PaymentTopUpErr::PartialPayment">>;
|
|
56
69
|
dec: import("scale-ts").Decoder<import("@novasamatech/scale").CodecError<{
|
|
57
70
|
reason: string;
|
|
58
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
71
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
72
|
+
credited: bigint;
|
|
73
|
+
}, "PaymentTopUpErr::PartialPayment">>;
|
|
59
74
|
} & {
|
|
60
75
|
readonly InsufficientFunds: import("@novasamatech/scale").ErrCodec<undefined, "PaymentTopUpErr::InsufficientFunds">;
|
|
61
76
|
readonly InvalidSource: import("@novasamatech/scale").ErrCodec<undefined, "PaymentTopUpErr::InvalidSource">;
|
|
77
|
+
readonly PartialPayment: import("@novasamatech/scale").ErrCodec<{
|
|
78
|
+
credited: bigint;
|
|
79
|
+
}, "PaymentTopUpErr::PartialPayment">;
|
|
62
80
|
readonly Unknown: import("@novasamatech/scale").ErrCodec<{
|
|
63
81
|
reason: string;
|
|
64
82
|
}, "PaymentTopUpErr::Unknown">;
|
|
65
83
|
} & {
|
|
66
84
|
[Symbol.hasInstance](v: unknown): v is import("@novasamatech/scale").CodecError<{
|
|
67
85
|
reason: string;
|
|
68
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
86
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
87
|
+
credited: bigint;
|
|
88
|
+
}, "PaymentTopUpErr::PartialPayment">;
|
|
69
89
|
};
|
|
70
90
|
export declare const PaymentRequestErr: [import("scale-ts").Encoder<import("@novasamatech/scale").CodecError<undefined, "PaymentRequestErr::Rejected"> | import("@novasamatech/scale").CodecError<{
|
|
71
91
|
reason: string;
|
|
@@ -146,11 +166,16 @@ export declare const PaymentTopUpV1_request: import("scale-ts").Codec<{
|
|
|
146
166
|
} | {
|
|
147
167
|
tag: "PrivateKey";
|
|
148
168
|
value: Uint8Array<ArrayBufferLike>;
|
|
169
|
+
} | {
|
|
170
|
+
tag: "Coins";
|
|
171
|
+
value: Uint8Array<ArrayBufferLike>[];
|
|
149
172
|
};
|
|
150
173
|
}>;
|
|
151
174
|
export declare const PaymentTopUpV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
|
|
152
175
|
reason: string;
|
|
153
|
-
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"
|
|
176
|
+
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource"> | import("@novasamatech/scale").CodecError<{
|
|
177
|
+
credited: bigint;
|
|
178
|
+
}, "PaymentTopUpErr::PartialPayment">>>;
|
|
154
179
|
export declare const PaymentRequestV1_request: import("scale-ts").Codec<{
|
|
155
180
|
from: number | undefined;
|
|
156
181
|
amount: bigint;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Enum, ErrEnum } from '@novasamatech/scale';
|
|
2
|
-
import { Bytes, Option, Result, Struct, _void, str, u128, u32 } from 'scale-ts';
|
|
2
|
+
import { Bytes, Option, Result, Struct, Vector, _void, str, u128, u32 } from 'scale-ts';
|
|
3
3
|
import { GenericErr } from '../commonCodecs.js';
|
|
4
4
|
import { DerivationIndex } from './accounts.js';
|
|
5
5
|
// common types
|
|
6
6
|
export const Ed25519PrivateKey = Bytes(32);
|
|
7
|
+
export const Sr25519SecretKey = Bytes(32);
|
|
7
8
|
export const PaymentId = str;
|
|
8
9
|
// Optional purse selector (RFC 0017). `undefined` (None) targets MAIN_PURSE.
|
|
9
10
|
export const CoinPaymentPurseId = u32;
|
|
10
11
|
export const PaymentTopUpSource = Enum({
|
|
11
12
|
ProductAccount: DerivationIndex,
|
|
12
13
|
PrivateKey: Ed25519PrivateKey,
|
|
14
|
+
Coins: Vector(Sr25519SecretKey),
|
|
13
15
|
});
|
|
14
16
|
export const PaymentBalance = Struct({
|
|
15
17
|
available: u128,
|
|
@@ -27,9 +29,14 @@ export const PaymentBalanceErr = ErrEnum('PaymentBalanceErr', {
|
|
|
27
29
|
PermissionDenied: [_void, 'permission denied'],
|
|
28
30
|
Unknown: [GenericErr, 'unknown error'],
|
|
29
31
|
});
|
|
32
|
+
// Carries the amount that was credited when only some coins could be claimed.
|
|
33
|
+
export const PartialPaymentErr = Struct({
|
|
34
|
+
credited: u128,
|
|
35
|
+
});
|
|
30
36
|
export const PaymentTopUpErr = ErrEnum('PaymentTopUpErr', {
|
|
31
37
|
InsufficientFunds: [_void, 'insufficient funds'],
|
|
32
38
|
InvalidSource: [_void, 'invalid source'],
|
|
39
|
+
PartialPayment: [PartialPaymentErr, ({ credited }) => `partial payment: credited ${credited}`],
|
|
33
40
|
Unknown: [GenericErr, 'unknown error'],
|
|
34
41
|
});
|
|
35
42
|
export const PaymentRequestErr = ErrEnum('PaymentRequestErr', {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.3",
|
|
5
5
|
"description": "Host API: transport implementation for host - product integration.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@novasamatech/scale": "0.8.
|
|
25
|
+
"@novasamatech/scale": "0.8.3",
|
|
26
26
|
"nanoevents": "9.1.0",
|
|
27
27
|
"nanoid": "5.1.11",
|
|
28
28
|
"neverthrow": "^8.2.0",
|