@novasamatech/host-api-wrapper 0.8.0-0 → 0.8.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 CHANGED
@@ -16,7 +16,7 @@ export { createLocalStorage, hostLocalStorage } from './localStorage.js';
16
16
  export type { NotificationId, PushNotificationInput } from './notification.js';
17
17
  export { createNotificationManager, notificationManager } from './notification.js';
18
18
  export { createPreimageManager, preimageManager } from './preimage.js';
19
- export type { PaymentBalance, PaymentStatus, TopUpSource } from './payments.js';
19
+ export type { PaymentBalance, PaymentStatus, PurseId, TopUpSource } from './payments.js';
20
20
  export { createPaymentManager, paymentManager } from './payments.js';
21
21
  export { deriveEntropy } from './deriveEntropy.js';
22
22
  export type { DevicePermissionKind, RemotePermissionItem } from './permission.js';
@@ -195,7 +195,7 @@ __fallback, internal) {
195
195
  const [followSubId, hash, items, childTrie] = params;
196
196
  const typedItems = items.map(item => ({
197
197
  key: item.key,
198
- type: convertStorageTypeToTyped(item.type),
198
+ queryType: convertStorageTypeToTyped(item.type),
199
199
  }));
200
200
  hostApi
201
201
  .chainHeadStorage(enumValue(version, {
@@ -17,18 +17,20 @@ export type TopUpSource = {
17
17
  type: 'privateKey';
18
18
  key: Uint8Array;
19
19
  };
20
+ /** CoinPayment purse identifier (RFC 0017). Omit to target the main purse. */
21
+ export type PurseId = number;
20
22
  export declare const createPaymentManager: (transport?: Transport) => {
21
- subscribeBalance(callback: (balance: PaymentBalance) => void): Subscription<CodecType<typeof PaymentBalanceErr>>;
22
- topUp(amount: bigint, source: TopUpSource): Promise<void>;
23
- requestPayment(amount: bigint, destination: Uint8Array): Promise<{
23
+ subscribeBalance(callback: (balance: PaymentBalance) => void, purse?: PurseId): Subscription<CodecType<typeof PaymentBalanceErr>>;
24
+ topUp(amount: bigint, source: TopUpSource, into?: PurseId): Promise<void>;
25
+ requestPayment(amount: bigint, destination: Uint8Array, from?: PurseId): Promise<{
24
26
  id: string;
25
27
  }>;
26
28
  subscribePaymentStatus(id: string, callback: (status: PaymentStatus) => void): Subscription;
27
29
  };
28
30
  export declare const paymentManager: {
29
- subscribeBalance(callback: (balance: PaymentBalance) => void): Subscription<CodecType<typeof PaymentBalanceErr>>;
30
- topUp(amount: bigint, source: TopUpSource): Promise<void>;
31
- requestPayment(amount: bigint, destination: Uint8Array): Promise<{
31
+ subscribeBalance(callback: (balance: PaymentBalance) => void, purse?: PurseId): Subscription<CodecType<typeof PaymentBalanceErr>>;
32
+ topUp(amount: bigint, source: TopUpSource, into?: PurseId): Promise<void>;
33
+ requestPayment(amount: bigint, destination: Uint8Array, from?: PurseId): Promise<{
32
34
  id: string;
33
35
  }>;
34
36
  subscribePaymentStatus(id: string, callback: (status: PaymentStatus) => void): Subscription;
package/dist/payments.js CHANGED
@@ -5,8 +5,8 @@ export const createPaymentManager = (transport = sandboxTransport) => {
5
5
  const hostApi = createHostApi(transport);
6
6
  const version = 'v1';
7
7
  return {
8
- subscribeBalance(callback) {
9
- const subscriber = hostApi.paymentBalanceSubscribe(enumValue(version, undefined), payload => {
8
+ subscribeBalance(callback, purse) {
9
+ const subscriber = hostApi.paymentBalanceSubscribe(enumValue(version, { purse }), payload => {
10
10
  if (payload.tag === version) {
11
11
  callback(payload.value);
12
12
  }
@@ -16,17 +16,17 @@ export const createPaymentManager = (transport = sandboxTransport) => {
16
16
  onInterrupt: cb => subscriber.onInterrupt(v => cb(v.value)),
17
17
  };
18
18
  },
19
- topUp(amount, source) {
19
+ topUp(amount, source, into) {
20
20
  const sourceCodec = source.type === 'productAccount'
21
21
  ? {
22
22
  tag: 'ProductAccount',
23
23
  value: source.derivationIndex,
24
24
  }
25
25
  : { tag: 'PrivateKey', value: source.key };
26
- return resultToPromise(unwrapVersionedResult(version, hostApi.paymentTopUp(enumValue(version, { amount, source: sourceCodec }))));
26
+ return resultToPromise(unwrapVersionedResult(version, hostApi.paymentTopUp(enumValue(version, { into, amount, source: sourceCodec }))));
27
27
  },
28
- requestPayment(amount, destination) {
29
- return resultToPromise(unwrapVersionedResult(version, hostApi.paymentRequest(enumValue(version, { amount, destination }))));
28
+ requestPayment(amount, destination, from) {
29
+ return resultToPromise(unwrapVersionedResult(version, hostApi.paymentRequest(enumValue(version, { from, amount, destination }))));
30
30
  },
31
31
  subscribePaymentStatus(id, callback) {
32
32
  return hostApi.paymentStatusSubscribe(enumValue(version, id), payload => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-api-wrapper",
3
3
  "type": "module",
4
- "version": "0.8.0-0",
4
+ "version": "0.8.0",
5
5
  "description": "Host API wrapper: integrate and run your product inside Polkadot browser.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "@polkadot/extension-inject": "^0.63.1",
29
29
  "@polkadot-api/json-rpc-provider-proxy": "^0.4.0",
30
30
  "@polkadot-api/substrate-bindings": "^0.20.2",
31
- "@novasamatech/host-api": "0.8.0-0",
31
+ "@novasamatech/host-api": "0.8.0",
32
32
  "polkadot-api": ">=2",
33
33
  "neverthrow": "^8.2.0"
34
34
  },