@novasamatech/host-container 0.5.0-0 → 0.5.0-10

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.
@@ -1,8 +1,11 @@
1
1
  import { createTransport } from '@novasamatech/host-api';
2
2
  import { createComplexSubscriber } from './createComplexSubscriber.js';
3
- function formatError(e) {
3
+ function formatOk(value) {
4
+ return { tag: 'Ok', value };
5
+ }
6
+ function formatErr(e) {
4
7
  const message = e instanceof Error ? e.message : typeof e === 'string' ? e : 'Unknown error';
5
- return { tag: 'error', value: message };
8
+ return { tag: 'Err', value: message };
6
9
  }
7
10
  const defaultHandlers = {
8
11
  accounts: {
@@ -31,13 +34,13 @@ export function createContainer(provider, params) {
31
34
  const accounts = await handler.get();
32
35
  return {
33
36
  tag: 'getAccountsResponseV1',
34
- value: { tag: 'success', value: accounts },
37
+ value: formatOk(accounts),
35
38
  };
36
39
  }
37
40
  catch (e) {
38
41
  return {
39
42
  tag: 'getAccountsResponseV1',
40
- value: formatError(e),
43
+ value: formatErr(e),
41
44
  };
42
45
  }
43
46
  });
@@ -52,7 +55,7 @@ export function createContainer(provider, params) {
52
55
  return subscriber(accounts => {
53
56
  callback({
54
57
  tag: 'getAccountsResponseV1',
55
- value: { tag: 'success', value: accounts },
58
+ value: formatOk(accounts),
56
59
  });
57
60
  });
58
61
  };
@@ -66,13 +69,13 @@ export function createContainer(provider, params) {
66
69
  const result = await signRaw(message);
67
70
  return {
68
71
  tag: 'signResponseV1',
69
- value: { tag: 'success', value: result },
72
+ value: formatOk(result),
70
73
  };
71
74
  }
72
75
  catch (e) {
73
76
  return {
74
77
  tag: 'signResponseV1',
75
- value: formatError(e),
78
+ value: formatErr(e),
76
79
  };
77
80
  }
78
81
  });
@@ -82,13 +85,13 @@ export function createContainer(provider, params) {
82
85
  const result = await signPayload(message);
83
86
  return {
84
87
  tag: 'signResponseV1',
85
- value: { tag: 'success', value: result },
88
+ value: formatOk(result),
86
89
  };
87
90
  }
88
91
  catch (e) {
89
92
  return {
90
93
  tag: 'signResponseV1',
91
- value: formatError(e),
94
+ value: formatErr(e),
92
95
  };
93
96
  }
94
97
  });
@@ -98,13 +101,13 @@ export function createContainer(provider, params) {
98
101
  const result = await createTransaction(message);
99
102
  return {
100
103
  tag: 'createTransactionResponseV1',
101
- value: { tag: 'success', value: result },
104
+ value: formatOk(result),
102
105
  };
103
106
  }
104
107
  catch (e) {
105
108
  return {
106
109
  tag: 'createTransactionResponseV1',
107
- value: formatError(e),
110
+ value: formatErr(e),
108
111
  };
109
112
  }
110
113
  });
@@ -116,16 +119,13 @@ export function createContainer(provider, params) {
116
119
  const result = await checkChainSupport(message.value.chainId);
117
120
  return {
118
121
  tag: 'supportFeatureResponseV1',
119
- value: {
120
- tag: 'success',
121
- value: { tag: 'chain', value: { chainId: message.value.chainId, result } },
122
- },
122
+ value: formatOk({ tag: 'chain', value: { chainId: message.value.chainId, result } }),
123
123
  };
124
124
  }
125
125
  catch (e) {
126
126
  return {
127
127
  tag: 'supportFeatureResponseV1',
128
- value: formatError(e),
128
+ value: formatErr(e),
129
129
  };
130
130
  }
131
131
  }
@@ -143,7 +143,7 @@ export function createContainer(provider, params) {
143
143
  connection = provider(message => {
144
144
  transport.postMessage('_', {
145
145
  tag: 'papiProviderReceiveMessageV1',
146
- value: { tag: 'success', value: { chainId, message } },
146
+ value: { tag: 'Ok', value: { chainId, message } },
147
147
  });
148
148
  });
149
149
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-container",
3
3
  "type": "module",
4
- "version": "0.5.0-0",
4
+ "version": "0.5.0-10",
5
5
  "description": "Host container for hosting and managing products within the Polkadot ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -26,8 +26,8 @@
26
26
  "README.md"
27
27
  ],
28
28
  "dependencies": {
29
- "@polkadot-api/json-rpc-provider": "0.0.4",
30
- "@novasamatech/host-api": "0.4.1"
29
+ "@polkadot-api/json-rpc-provider": "^0.0.4",
30
+ "@novasamatech/host-api": "0.5.0-10"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"