@cardano-sdk/cardano-services-client 0.17.9 → 0.18.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/cjs/TxSubmitProvider/TxSubmitApiProvider.d.ts +10 -1
- package/dist/cjs/TxSubmitProvider/TxSubmitApiProvider.d.ts.map +1 -1
- package/dist/cjs/TxSubmitProvider/TxSubmitApiProvider.js +9 -6
- package/dist/cjs/TxSubmitProvider/TxSubmitApiProvider.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/TxSubmitProvider/TxSubmitApiProvider.d.ts +10 -1
- package/dist/esm/TxSubmitProvider/TxSubmitApiProvider.d.ts.map +1 -1
- package/dist/esm/TxSubmitProvider/TxSubmitApiProvider.js +9 -6
- package/dist/esm/TxSubmitProvider/TxSubmitApiProvider.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/package.json +4 -4
- package/package.json +4 -4
package/dist/cjs/version.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { SubmitTxArgs, TxSubmitProvider } from '@cardano-sdk/core';
|
|
2
2
|
import { Logger } from 'ts-log';
|
|
3
|
+
import { AxiosAdapter } from 'axios';
|
|
4
|
+
export declare type TxSubmitApiProviderProperties = {
|
|
5
|
+
baseUrl: URL;
|
|
6
|
+
path?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type TxSubmitApiProviderDependencies = {
|
|
9
|
+
logger: Logger;
|
|
10
|
+
adapter?: AxiosAdapter;
|
|
11
|
+
};
|
|
3
12
|
export declare class TxSubmitApiProvider implements TxSubmitProvider {
|
|
4
13
|
#private;
|
|
5
|
-
constructor(
|
|
14
|
+
constructor({ baseUrl, path }: TxSubmitApiProviderProperties, { logger, adapter }: TxSubmitApiProviderDependencies);
|
|
6
15
|
submitTx({ signedTransaction }: SubmitTxArgs): Promise<void>;
|
|
7
16
|
healthCheck(): Promise<{
|
|
8
17
|
ok: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxSubmitApiProvider.d.ts","sourceRoot":"","sources":["../../../src/TxSubmitProvider/TxSubmitApiProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,YAAY,EAAc,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"TxSubmitApiProvider.d.ts","sourceRoot":"","sources":["../../../src/TxSubmitProvider/TxSubmitApiProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,YAAY,EAAc,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAc,EAAE,YAAY,EAAiB,MAAM,OAAO,CAAC;AAE3D,oBAAY,6BAA6B,GAAG;IAC1C,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,+BAA+B,GAAG;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,qBAAa,mBAAoB,YAAW,gBAAgB;;gBAQxD,EAAE,OAAO,EAAE,IAAuB,EAAE,EAAE,6BAA6B,EACnE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,+BAA+B;IAQhD,QAAQ,CAAC,EAAE,iBAAiB,EAAE,EAAE,YAAY;IAuClD,WAAW;;;CAGZ"}
|
|
@@ -9,20 +9,22 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _TxSubmitApiProvider_axios, _TxSubmitApiProvider_healthStatus, _TxSubmitApiProvider_logger, _TxSubmitApiProvider_path;
|
|
12
|
+
var _TxSubmitApiProvider_axios, _TxSubmitApiProvider_healthStatus, _TxSubmitApiProvider_logger, _TxSubmitApiProvider_path, _TxSubmitApiProvider_adapter;
|
|
13
13
|
import { Cardano, ProviderError, ProviderFailure, TxBodyCBOR } from '@cardano-sdk/core';
|
|
14
14
|
import { hexStringToBuffer } from '@cardano-sdk/util';
|
|
15
15
|
import { mapCardanoTxSubmitError } from './cardanoTxSubmitErrorMapper';
|
|
16
16
|
import axios from 'axios';
|
|
17
17
|
export class TxSubmitApiProvider {
|
|
18
|
-
constructor(
|
|
18
|
+
constructor({ baseUrl, path = '/api/submit/tx' }, { logger, adapter }) {
|
|
19
19
|
_TxSubmitApiProvider_axios.set(this, void 0);
|
|
20
20
|
_TxSubmitApiProvider_healthStatus.set(this, true);
|
|
21
21
|
_TxSubmitApiProvider_logger.set(this, void 0);
|
|
22
22
|
_TxSubmitApiProvider_path.set(this, void 0);
|
|
23
|
-
|
|
23
|
+
_TxSubmitApiProvider_adapter.set(this, void 0);
|
|
24
|
+
__classPrivateFieldSet(this, _TxSubmitApiProvider_axios, axios.create({ baseURL: baseUrl.origin }), "f");
|
|
24
25
|
__classPrivateFieldSet(this, _TxSubmitApiProvider_logger, logger, "f");
|
|
25
|
-
__classPrivateFieldSet(this, _TxSubmitApiProvider_path,
|
|
26
|
+
__classPrivateFieldSet(this, _TxSubmitApiProvider_path, path, "f");
|
|
27
|
+
__classPrivateFieldSet(this, _TxSubmitApiProvider_adapter, adapter, "f");
|
|
26
28
|
}
|
|
27
29
|
async submitTx({ signedTransaction }) {
|
|
28
30
|
let txId;
|
|
@@ -30,6 +32,7 @@ export class TxSubmitApiProvider {
|
|
|
30
32
|
txId = Cardano.TransactionId.fromTxBodyCbor(TxBodyCBOR.fromTxCBOR(signedTransaction));
|
|
31
33
|
__classPrivateFieldGet(this, _TxSubmitApiProvider_logger, "f").debug(`Submitting tx ${txId} ...`);
|
|
32
34
|
await __classPrivateFieldGet(this, _TxSubmitApiProvider_axios, "f").call(this, {
|
|
35
|
+
adapter: __classPrivateFieldGet(this, _TxSubmitApiProvider_adapter, "f"),
|
|
33
36
|
data: hexStringToBuffer(signedTransaction),
|
|
34
37
|
headers: { 'Content-Type': 'application/cbor' },
|
|
35
38
|
method: 'post',
|
|
@@ -46,7 +49,7 @@ export class TxSubmitApiProvider {
|
|
|
46
49
|
const { data, status } = error.response;
|
|
47
50
|
if (typeof status === 'number' && status >= 400 && status < 500)
|
|
48
51
|
__classPrivateFieldSet(this, _TxSubmitApiProvider_healthStatus, true, "f");
|
|
49
|
-
throw new ProviderError(ProviderFailure.BadRequest, mapCardanoTxSubmitError(data), data);
|
|
52
|
+
throw new ProviderError(ProviderFailure.BadRequest, mapCardanoTxSubmitError(data), typeof data === 'string' ? data : JSON.stringify(data));
|
|
50
53
|
}
|
|
51
54
|
throw new ProviderError(ProviderFailure.Unknown, error, 'submitting tx');
|
|
52
55
|
}
|
|
@@ -55,5 +58,5 @@ export class TxSubmitApiProvider {
|
|
|
55
58
|
return Promise.resolve({ ok: __classPrivateFieldGet(this, _TxSubmitApiProvider_healthStatus, "f") });
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
|
-
_TxSubmitApiProvider_axios = new WeakMap(), _TxSubmitApiProvider_healthStatus = new WeakMap(), _TxSubmitApiProvider_logger = new WeakMap(), _TxSubmitApiProvider_path = new WeakMap();
|
|
61
|
+
_TxSubmitApiProvider_axios = new WeakMap(), _TxSubmitApiProvider_healthStatus = new WeakMap(), _TxSubmitApiProvider_logger = new WeakMap(), _TxSubmitApiProvider_path = new WeakMap(), _TxSubmitApiProvider_adapter = new WeakMap();
|
|
59
62
|
//# sourceMappingURL=TxSubmitApiProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxSubmitApiProvider.js","sourceRoot":"","sources":["../../../src/TxSubmitProvider/TxSubmitApiProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAgB,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AAExH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"TxSubmitApiProvider.js","sourceRoot":"","sources":["../../../src/TxSubmitProvider/TxSubmitApiProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAgB,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AAExH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAsC,MAAM,OAAO,CAAC;AAY3D,MAAM,OAAO,mBAAmB;IAO9B,YACE,EAAE,OAAO,EAAE,IAAI,GAAG,gBAAgB,EAAiC,EACnE,EAAE,MAAM,EAAE,OAAO,EAAmC;QARtD,6CAAsB;QACtB,4CAAgB,IAAI,EAAC;QACrB,8CAAgB;QAChB,4CAAc;QACd,+CAAwB;QAMtB,uBAAA,IAAI,8BAAU,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,MAAA,CAAC;QACxD,uBAAA,IAAI,+BAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,6BAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,gCAAY,OAAO,MAAA,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAE,iBAAiB,EAAgB;QAChD,IAAI,IAAuC,CAAC;QAE5C,IAAI;YACF,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,C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