@novasamatech/product-sdk 0.7.9-2 → 0.7.9-4
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/accounts.js +1 -1
- package/dist/injectWeb3.js +1 -1
- package/package.json +2 -2
- package/dist/createMetaProvider.d.ts +0 -7
- package/dist/createMetaProvider.js +0 -24
- package/dist/createPapiProvider.d.ts +0 -7
- package/dist/createPapiProvider.js +0 -56
- package/dist/defaultTransport.d.ts +0 -3
- package/dist/defaultTransport.js +0 -57
- package/dist/injectSpektrExtension.d.ts +0 -24
- package/dist/injectSpektrExtension.js +0 -121
- package/dist/signer.d.ts +0 -17
- package/dist/signer.js +0 -71
package/dist/accounts.js
CHANGED
|
@@ -153,7 +153,7 @@ export const createAccountsProvider = (transport = sandboxTransport) => {
|
|
|
153
153
|
}
|
|
154
154
|
const txPayload = {
|
|
155
155
|
signer: productAccountId,
|
|
156
|
-
genesisHash: checkGenesis.
|
|
156
|
+
genesisHash: checkGenesis.additionalSigned,
|
|
157
157
|
callData,
|
|
158
158
|
extensions: Object.values(signedExtensions).map(({ identifier, value, additionalSigned }) => ({
|
|
159
159
|
id: identifier,
|
package/dist/injectWeb3.js
CHANGED
|
@@ -115,7 +115,7 @@ export async function createLegacyExtensionEnableFactory(transport) {
|
|
|
115
115
|
const possibleAccountId = accountId.enc(signer);
|
|
116
116
|
const response = await hostApi.createTransactionWithLegacyAccount(enumValue('v1', {
|
|
117
117
|
signer: possibleAccountId,
|
|
118
|
-
genesisHash: fromHex(checkGenesis.
|
|
118
|
+
genesisHash: fromHex(checkGenesis.additionalSigned),
|
|
119
119
|
callData: fromHex(payload.callData),
|
|
120
120
|
txExtVersion: payload.txExtVersion,
|
|
121
121
|
extensions: payload.extensions.map(e => ({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/product-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.9-
|
|
4
|
+
"version": "0.7.9-4",
|
|
5
5
|
"description": "Polkadot product SDK: 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.7.9-
|
|
31
|
+
"@novasamatech/host-api": "0.7.9-4",
|
|
32
32
|
"polkadot-api": ">=2",
|
|
33
33
|
"neverthrow": "^8.2.0"
|
|
34
34
|
},
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ConnectionStatus, Transport } from '@novasamatech/host-api';
|
|
2
|
-
export declare function createMetaProvider(transport?: Transport): {
|
|
3
|
-
subscribeConnectionStatus(callback: (connectionStatus: ConnectionStatus) => void): VoidFunction;
|
|
4
|
-
};
|
|
5
|
-
export declare const metaProvider: {
|
|
6
|
-
subscribeConnectionStatus(callback: (connectionStatus: ConnectionStatus) => void): VoidFunction;
|
|
7
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defaultTransport } from './defaultTransport.js';
|
|
2
|
-
export function createMetaProvider(transport = defaultTransport) {
|
|
3
|
-
// if (transport.isCorrectEnvironment() && typeof window !== 'undefined') {
|
|
4
|
-
// const getUrl = () => {
|
|
5
|
-
// return window.location.pathname + window.location.hash + window.location.search;
|
|
6
|
-
// };
|
|
7
|
-
//
|
|
8
|
-
// window.addEventListener('hashchange', () => {
|
|
9
|
-
// transport.postMessage('_', { tag: 'locationChangedV1', value: getUrl() });
|
|
10
|
-
// });
|
|
11
|
-
//
|
|
12
|
-
// window.addEventListener('popstate', () => {
|
|
13
|
-
// transport.postMessage('_', { tag: 'locationChangedV1', value: getUrl() });
|
|
14
|
-
// });
|
|
15
|
-
//
|
|
16
|
-
// transport.postMessage('_', { tag: 'locationChangedV1', value: getUrl() });
|
|
17
|
-
// }
|
|
18
|
-
return {
|
|
19
|
-
subscribeConnectionStatus(callback) {
|
|
20
|
-
return transport.onConnectionStatusChange(callback);
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export const metaProvider = createMetaProvider();
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { HexString, Transport } from '@novasamatech/host-api';
|
|
2
|
-
import type { JsonRpcProvider } from '@polkadot-api/json-rpc-provider';
|
|
3
|
-
type InternalParams = {
|
|
4
|
-
transport?: Transport;
|
|
5
|
-
};
|
|
6
|
-
export declare function createPapiProvider(genesisHash: HexString, internal?: InternalParams): JsonRpcProvider;
|
|
7
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { createHostApi, enumValue, unwrapResultOrThrow } from '@novasamatech/host-api';
|
|
2
|
-
import { getSyncProvider } from '@polkadot-api/json-rpc-provider-proxy';
|
|
3
|
-
import { defaultTransport } from './defaultTransport.js';
|
|
4
|
-
export function createPapiProvider(genesisHash, internal) {
|
|
5
|
-
const version = 'v1';
|
|
6
|
-
const transport = internal?.transport ?? defaultTransport;
|
|
7
|
-
if (!transport.isCorrectEnvironment()) {
|
|
8
|
-
throw new Error('PapiProvider can only be used in a product environment');
|
|
9
|
-
}
|
|
10
|
-
const hostApi = createHostApi(transport);
|
|
11
|
-
const spektrProvider = onMessage => {
|
|
12
|
-
const subscription = hostApi.jsonrpcMessageSubscribe(enumValue(version, genesisHash), payload => {
|
|
13
|
-
switch (payload.tag) {
|
|
14
|
-
case version:
|
|
15
|
-
onMessage(payload.value);
|
|
16
|
-
break;
|
|
17
|
-
default:
|
|
18
|
-
transport.provider.logger.error('Unknown message version', payload.tag);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
send(message) {
|
|
23
|
-
hostApi.jsonrpcMessageSend(enumValue(version, [genesisHash, message]));
|
|
24
|
-
},
|
|
25
|
-
disconnect() {
|
|
26
|
-
subscription.unsubscribe();
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
function checkIfReady() {
|
|
31
|
-
return transport.isReady().then(ready => {
|
|
32
|
-
if (!ready)
|
|
33
|
-
return false;
|
|
34
|
-
return transport
|
|
35
|
-
.request('feature', enumValue('v1', enumValue('Chain', genesisHash)))
|
|
36
|
-
.then(payload => {
|
|
37
|
-
switch (payload.tag) {
|
|
38
|
-
case 'v1': {
|
|
39
|
-
return unwrapResultOrThrow(payload.value, e => new Error(e.payload.reason));
|
|
40
|
-
}
|
|
41
|
-
default:
|
|
42
|
-
throw new Error(`Unknown message version ${payload.tag}`);
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
.catch(e => {
|
|
46
|
-
transport.provider.logger.error('Error checking chain support', e);
|
|
47
|
-
return false;
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return getSyncProvider(() => checkIfReady().then(ready => {
|
|
52
|
-
if (ready)
|
|
53
|
-
return spektrProvider;
|
|
54
|
-
throw new Error(`Chain ${genesisHash} not supported by host`);
|
|
55
|
-
}));
|
|
56
|
-
}
|
package/dist/defaultTransport.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { createDefaultLogger, createTransport } from '@novasamatech/host-api';
|
|
2
|
-
function getParentWindow() {
|
|
3
|
-
if (window.top) {
|
|
4
|
-
return window.top;
|
|
5
|
-
}
|
|
6
|
-
throw new Error('No parent window found');
|
|
7
|
-
}
|
|
8
|
-
function isIframe() {
|
|
9
|
-
try {
|
|
10
|
-
return window !== window.top;
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function isValidMessage(event, sourceEnv, currentEnv) {
|
|
17
|
-
return (event.source !== currentEnv &&
|
|
18
|
-
event.source === sourceEnv &&
|
|
19
|
-
event.data &&
|
|
20
|
-
event.data.constructor.name === 'Uint8Array');
|
|
21
|
-
}
|
|
22
|
-
function createDefaultSdkProvider() {
|
|
23
|
-
const subscribers = new Set();
|
|
24
|
-
const handleMessage = (event) => {
|
|
25
|
-
if (!isValidMessage(event, getParentWindow(), window))
|
|
26
|
-
return;
|
|
27
|
-
for (const subscriber of subscribers) {
|
|
28
|
-
subscriber(event.data);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
if (isIframe()) {
|
|
32
|
-
window.addEventListener('message', handleMessage);
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
logger: createDefaultLogger(),
|
|
36
|
-
isCorrectEnvironment() {
|
|
37
|
-
return isIframe();
|
|
38
|
-
},
|
|
39
|
-
postMessage(message) {
|
|
40
|
-
getParentWindow().postMessage(message, '*', [message.buffer]);
|
|
41
|
-
},
|
|
42
|
-
subscribe(callback) {
|
|
43
|
-
subscribers.add(callback);
|
|
44
|
-
return () => {
|
|
45
|
-
subscribers.delete(callback);
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
dispose() {
|
|
49
|
-
subscribers.clear();
|
|
50
|
-
if (isIframe()) {
|
|
51
|
-
window.removeEventListener('message', handleMessage);
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export const defaultProvider = createDefaultSdkProvider();
|
|
57
|
-
export const defaultTransport = createTransport(defaultProvider);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { CodecType, HexString, Transport, VersionedPublicTxPayload } from '@novasamatech/host-api';
|
|
2
|
-
import type { InjectedAccounts } from '@polkadot/extension-inject/types';
|
|
3
|
-
import type { SignerPayloadJSON, SignerPayloadRaw, SignerResult } from '@polkadot/types/types/extrinsic';
|
|
4
|
-
interface Signer {
|
|
5
|
-
/**
|
|
6
|
-
* @description signs an extrinsic payload from a serialized form
|
|
7
|
-
*/
|
|
8
|
-
signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
|
|
9
|
-
/**
|
|
10
|
-
* @description signs a raw payload, only the bytes data as supplied
|
|
11
|
-
*/
|
|
12
|
-
signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
|
|
13
|
-
/**
|
|
14
|
-
* @description signs a transaction according to https://github.com/polkadot-js/api/issues/6213
|
|
15
|
-
*/
|
|
16
|
-
createTransaction?: (payload: CodecType<typeof VersionedPublicTxPayload>) => Promise<HexString>;
|
|
17
|
-
}
|
|
18
|
-
interface Injected {
|
|
19
|
-
accounts: InjectedAccounts;
|
|
20
|
-
signer: Signer;
|
|
21
|
-
}
|
|
22
|
-
export declare function createExtensionEnableFactory(transport: Transport): Promise<(() => Promise<Injected>) | null>;
|
|
23
|
-
export declare function injectSpektrExtension(transport?: Transport | null): Promise<boolean>;
|
|
24
|
-
export {};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { assertEnumVariant, createHostApi, enumValue, fromHex, toHex } from '@novasamatech/host-api';
|
|
2
|
-
import { injectExtension } from '@polkadot/extension-inject';
|
|
3
|
-
import { AccountId } from '@polkadot-api/substrate-bindings';
|
|
4
|
-
import { SpektrExtensionName, Version } from './constants.js';
|
|
5
|
-
import { defaultTransport } from './defaultTransport.js';
|
|
6
|
-
const UNSUPPORTED_VERSION_ERROR = 'Unsupported message version';
|
|
7
|
-
export async function createExtensionEnableFactory(transport) {
|
|
8
|
-
const ready = await transport.isReady();
|
|
9
|
-
if (!ready)
|
|
10
|
-
return null;
|
|
11
|
-
const hostApi = createHostApi(transport);
|
|
12
|
-
const accountId = AccountId();
|
|
13
|
-
async function enable() {
|
|
14
|
-
async function getAccounts() {
|
|
15
|
-
const response = await hostApi.getNonProductAccounts(enumValue('v1', undefined));
|
|
16
|
-
return response.match(response => {
|
|
17
|
-
assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
18
|
-
return response.value.map(account => ({
|
|
19
|
-
name: account.name,
|
|
20
|
-
address: accountId.dec(account.publicKey),
|
|
21
|
-
type: 'sr25519',
|
|
22
|
-
}));
|
|
23
|
-
}, err => {
|
|
24
|
-
assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
25
|
-
throw err.value;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
accounts: {
|
|
30
|
-
async get() {
|
|
31
|
-
return getAccounts();
|
|
32
|
-
},
|
|
33
|
-
subscribe(callback) {
|
|
34
|
-
getAccounts().then(callback);
|
|
35
|
-
return () => {
|
|
36
|
-
// empty
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
signer: {
|
|
41
|
-
async signRaw(raw) {
|
|
42
|
-
const payload = {
|
|
43
|
-
address: raw.address,
|
|
44
|
-
data: raw.type === 'bytes'
|
|
45
|
-
? {
|
|
46
|
-
tag: 'Bytes',
|
|
47
|
-
value: fromHex(raw.data),
|
|
48
|
-
}
|
|
49
|
-
: {
|
|
50
|
-
tag: 'Payload',
|
|
51
|
-
value: raw.data,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
const response = await hostApi.signRaw(enumValue('v1', payload));
|
|
55
|
-
return response.match(response => {
|
|
56
|
-
assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
57
|
-
return {
|
|
58
|
-
id: 0,
|
|
59
|
-
signature: response.value.signature,
|
|
60
|
-
signedTransaction: response.value.signedTransaction,
|
|
61
|
-
};
|
|
62
|
-
}, err => {
|
|
63
|
-
assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
64
|
-
throw err.value;
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
async signPayload(payload) {
|
|
68
|
-
const codecPayload = {
|
|
69
|
-
...payload,
|
|
70
|
-
method: payload.method,
|
|
71
|
-
assetId: payload.assetId,
|
|
72
|
-
mode: payload.mode,
|
|
73
|
-
withSignedTransaction: payload.withSignedTransaction,
|
|
74
|
-
metadataHash: payload.metadataHash,
|
|
75
|
-
};
|
|
76
|
-
const response = await hostApi.signPayload(enumValue('v1', codecPayload));
|
|
77
|
-
return response.match(response => {
|
|
78
|
-
assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
79
|
-
return {
|
|
80
|
-
id: 0,
|
|
81
|
-
signature: response.value.signature,
|
|
82
|
-
signedTransaction: response.value.signedTransaction,
|
|
83
|
-
};
|
|
84
|
-
}, err => {
|
|
85
|
-
assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
86
|
-
throw err.value;
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
async createTransaction(payload) {
|
|
90
|
-
const response = await hostApi.createTransactionWithNonProductAccount(enumValue('v1', payload));
|
|
91
|
-
return response.match(response => {
|
|
92
|
-
assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
93
|
-
return toHex(response.value);
|
|
94
|
-
}, err => {
|
|
95
|
-
assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
96
|
-
throw err.value;
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return enable;
|
|
103
|
-
}
|
|
104
|
-
export async function injectSpektrExtension(transport = defaultTransport) {
|
|
105
|
-
if (!transport)
|
|
106
|
-
return false;
|
|
107
|
-
try {
|
|
108
|
-
const enable = await createExtensionEnableFactory(transport);
|
|
109
|
-
if (enable) {
|
|
110
|
-
injectExtension(enable, { name: SpektrExtensionName, version: Version });
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
transport.provider.logger.error('Error injecting extension', e);
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
package/dist/signer.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CodecType, ProductAccountId as ProductAccountIdCodec, Transport } from '@novasamatech/host-api';
|
|
2
|
-
import type { PolkadotSigner } from 'polkadot-api';
|
|
3
|
-
export type ProductAccountId = CodecType<typeof ProductAccountIdCodec>;
|
|
4
|
-
export type ProductSignerConfig = {
|
|
5
|
-
/** Native token symbol — used by hosts that compute CheckMetadataHash or render fees. Defaults to "". */
|
|
6
|
-
tokenSymbol?: string;
|
|
7
|
-
/** Native token decimals — see tokenSymbol. Defaults to 0. */
|
|
8
|
-
tokenDecimals?: number;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Builds a `PolkadotSigner` that delegates to the host via `host_create_transaction`
|
|
12
|
-
* (the new signing flow described in https://github.com/polkadot-js/api/issues/6213).
|
|
13
|
-
*
|
|
14
|
-
* The factory is async because `PolkadotSigner.publicKey` must be a synchronous
|
|
15
|
-
* `Uint8Array` on the returned object — it is fetched up front via `host_account_get`.
|
|
16
|
-
*/
|
|
17
|
-
export declare const createProductSigner: (accountId: ProductAccountId, config?: ProductSignerConfig, transport?: Transport) => Promise<PolkadotSigner>;
|
package/dist/signer.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { assertEnumVariant, createHostApi, enumValue, fromHex, toHex } from '@novasamatech/host-api';
|
|
2
|
-
import { decAnyMetadata, unifyMetadata } from '@polkadot-api/substrate-bindings';
|
|
3
|
-
import { sandboxTransport } from './sandboxTransport.js';
|
|
4
|
-
const UNSUPPORTED_VERSION_ERROR = 'Unsupported message version';
|
|
5
|
-
/**
|
|
6
|
-
* Builds a `PolkadotSigner` that delegates to the host via `host_create_transaction`
|
|
7
|
-
* (the new signing flow described in https://github.com/polkadot-js/api/issues/6213).
|
|
8
|
-
*
|
|
9
|
-
* The factory is async because `PolkadotSigner.publicKey` must be a synchronous
|
|
10
|
-
* `Uint8Array` on the returned object — it is fetched up front via `host_account_get`.
|
|
11
|
-
*/
|
|
12
|
-
export const createProductSigner = async (accountId, config = {}, transport = sandboxTransport) => {
|
|
13
|
-
const hostApi = createHostApi(transport);
|
|
14
|
-
const accountResponse = await hostApi.accountGet(enumValue('v1', accountId));
|
|
15
|
-
const account = accountResponse.match(response => {
|
|
16
|
-
assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
17
|
-
return response.value;
|
|
18
|
-
}, err => {
|
|
19
|
-
assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
20
|
-
throw err.value;
|
|
21
|
-
});
|
|
22
|
-
const tokenSymbol = config.tokenSymbol ?? 'DOT';
|
|
23
|
-
const tokenDecimals = config.tokenDecimals ?? 12;
|
|
24
|
-
return {
|
|
25
|
-
publicKey: account.publicKey,
|
|
26
|
-
async signTx(callData, signedExtensions, metadata, atBlockNumber) {
|
|
27
|
-
const decMeta = unifyMetadata(decAnyMetadata(metadata));
|
|
28
|
-
const { version: versions } = decMeta.extrinsic;
|
|
29
|
-
const latestVersion = versions.reduce((acc, v) => Math.max(acc, v), 0);
|
|
30
|
-
const txExtVersion = latestVersion === 4 ? 0 : latestVersion;
|
|
31
|
-
const txPayload = {
|
|
32
|
-
version: 1,
|
|
33
|
-
signer: null,
|
|
34
|
-
callData,
|
|
35
|
-
extensions: Object.values(signedExtensions).map(({ identifier, value, additionalSigned }) => ({
|
|
36
|
-
id: identifier,
|
|
37
|
-
extra: value,
|
|
38
|
-
additionalSigned: additionalSigned,
|
|
39
|
-
})),
|
|
40
|
-
txExtVersion,
|
|
41
|
-
context: {
|
|
42
|
-
metadata: metadata,
|
|
43
|
-
tokenSymbol,
|
|
44
|
-
tokenDecimals,
|
|
45
|
-
bestBlockHeight: atBlockNumber,
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
const response = await hostApi.createTransaction(enumValue('v1', [accountId, txPayload]));
|
|
49
|
-
return response.match(response => {
|
|
50
|
-
assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
51
|
-
return response.value;
|
|
52
|
-
}, err => {
|
|
53
|
-
assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
54
|
-
throw err.value;
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
async signBytes(data) {
|
|
58
|
-
const response = await hostApi.signRaw(enumValue('v1', {
|
|
59
|
-
account: accountId,
|
|
60
|
-
payload: { tag: 'Bytes', value: data },
|
|
61
|
-
}));
|
|
62
|
-
return response.match(response => {
|
|
63
|
-
assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
64
|
-
return fromHex(response.value.signature);
|
|
65
|
-
}, err => {
|
|
66
|
-
assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
|
|
67
|
-
throw err.value;
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
};
|