@parity/product-sdk-host 0.13.0 → 0.14.0
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/index.d.ts +63 -47
- package/dist/index.js +28 -17
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +4 -3
- package/dist/testing.js +10 -1
- package/dist/testing.js.map +1 -1
- package/package.json +6 -5
- package/src/accounts.ts +101 -37
- package/src/chains.ts +3 -9
- package/src/errors.ts +77 -41
- package/src/index.ts +2 -0
- package/src/payments.ts +8 -7
- package/src/testing.ts +15 -4
package/src/payments.ts
CHANGED
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
* `truApi.payment.*`.
|
|
6
6
|
*
|
|
7
7
|
* Exposes balance subscription, top-up, payment requests, and payment-status
|
|
8
|
-
* subscription.
|
|
9
|
-
* (RFC-0017)
|
|
10
|
-
* flow
|
|
8
|
+
* subscription. The flow is distinct from the CoinPayment / merchant-payments
|
|
9
|
+
* surface (RFC-0017) — RFC-0006 is the user-initiated balance / top-up /
|
|
10
|
+
* payment-request flow — but both operate on the same CoinPayment purses,
|
|
11
|
+
* hence the shared `CoinPaymentPurseId` (omitted = the main purse).
|
|
11
12
|
*
|
|
12
13
|
* @module
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
import type {
|
|
16
17
|
Balance,
|
|
17
|
-
|
|
18
|
+
CoinPaymentPurseId,
|
|
18
19
|
HexString,
|
|
19
20
|
HostPaymentBalanceSubscribeItem,
|
|
20
21
|
HostPaymentStatusSubscribeItem,
|
|
@@ -37,13 +38,13 @@ import type { HostSubscription } from "./types.js";
|
|
|
37
38
|
export interface PaymentManager {
|
|
38
39
|
subscribeBalance(
|
|
39
40
|
callback: (balance: HostPaymentBalanceSubscribeItem) => void,
|
|
40
|
-
purse?:
|
|
41
|
+
purse?: CoinPaymentPurseId,
|
|
41
42
|
): HostSubscription;
|
|
42
|
-
topUp(amount: Balance, source: PaymentTopUpSource, into?:
|
|
43
|
+
topUp(amount: Balance, source: PaymentTopUpSource, into?: CoinPaymentPurseId): Promise<void>;
|
|
43
44
|
requestPayment(
|
|
44
45
|
amount: Balance,
|
|
45
46
|
destination: HexString,
|
|
46
|
-
from?:
|
|
47
|
+
from?: CoinPaymentPurseId,
|
|
47
48
|
): Promise<{ id: string }>;
|
|
48
49
|
subscribePaymentStatus(
|
|
49
50
|
paymentId: string,
|
package/src/testing.ts
CHANGED
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Not modeled: the PAPI `chain` JSON-RPC surface behind `getHostProvider()` —
|
|
14
14
|
* there's no chain-read fake, by design; the host owns RPC selection — and the
|
|
15
|
-
* `chat` / `
|
|
16
|
-
* `resourceAllocation` / `theme` domains. Touching an unmodeled
|
|
17
|
-
* descriptive error rather than failing with `undefined is not
|
|
15
|
+
* `chat` / `coinPayment` / `entropy` / `notifications` / `payment` /
|
|
16
|
+
* `permissions` / `resourceAllocation` / `theme` domains. Touching an unmodeled
|
|
17
|
+
* domain throws a descriptive error rather than failing with `undefined is not
|
|
18
|
+
* a function`.
|
|
18
19
|
*
|
|
19
20
|
* @packageDocumentation
|
|
20
21
|
*/
|
|
@@ -182,7 +183,16 @@ export function createFakeTruApiClient(options?: CreateFakeTruApiClientOptions):
|
|
|
182
183
|
getAccountAlias: () =>
|
|
183
184
|
okAsync({ context: toHex(new Uint8Array([1])), alias: toHex(new Uint8Array([2])) }),
|
|
184
185
|
getLegacyAccounts: () => okAsync({ accounts: legacyAccounts }),
|
|
185
|
-
createAccountProof: () =>
|
|
186
|
+
createAccountProof: () =>
|
|
187
|
+
okAsync({
|
|
188
|
+
proof: signature,
|
|
189
|
+
contextualAlias: {
|
|
190
|
+
context: toHex(new Uint8Array([1])),
|
|
191
|
+
alias: toHex(new Uint8Array([2])),
|
|
192
|
+
},
|
|
193
|
+
ringIndex: 0,
|
|
194
|
+
ringRevision: 0,
|
|
195
|
+
}),
|
|
186
196
|
connectionStatusSubscribe: () => inertObservable(),
|
|
187
197
|
},
|
|
188
198
|
signing: {
|
|
@@ -217,6 +227,7 @@ export function createFakeTruApiClient(options?: CreateFakeTruApiClientOptions):
|
|
|
217
227
|
},
|
|
218
228
|
chain: notModeled("chain"),
|
|
219
229
|
chat: notModeled("chat"),
|
|
230
|
+
coinPayment: notModeled("coinPayment"),
|
|
220
231
|
entropy: notModeled("entropy"),
|
|
221
232
|
notifications: notModeled("notifications"),
|
|
222
233
|
payment: notModeled("payment"),
|