@chainflip/sdk 0.2.10 → 0.2.12

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.
@@ -26,6 +26,18 @@ var submitAddress = /* @__PURE__ */ __name((asset, address) => {
26
26
  }
27
27
  return address;
28
28
  }, "submitAddress");
29
+ var rpcResult = z.union([
30
+ z.object({
31
+ error: z.object({
32
+ code: z.number().optional(),
33
+ message: z.string().optional(),
34
+ data: z.unknown().optional()
35
+ })
36
+ }),
37
+ z.object({
38
+ result: z.unknown()
39
+ })
40
+ ]);
29
41
  var requestValidators = {
30
42
  requestSwapDepositAddress: z.tuple([
31
43
  chainflipAsset.transform(transformAsset),
@@ -76,7 +88,11 @@ var makeRpcRequest = /* @__PURE__ */ __name(async (url, method, ...params) => {
76
88
  method: `broker_${method}`,
77
89
  params: requestValidators[method].parse(params)
78
90
  });
79
- return responseValidators[method].parse(res.data.result);
91
+ const result = rpcResult.parse(res.data);
92
+ if ("error" in result) {
93
+ throw new Error(`Broker responded with error code ${result.error.code}: ${result.error.message}`);
94
+ }
95
+ return responseValidators[method].parse(result.result);
80
96
  }, "makeRpcRequest");
81
97
  async function requestSwapDepositAddress(swapRequest, opts) {
82
98
  const { srcAsset, destAsset, destAddress } = swapRequest;
package/dist/swap.js CHANGED
@@ -4352,7 +4352,7 @@ async function requestSwapDepositAddress(swapRequest, opts) {
4352
4352
  cfParameters: void 0
4353
4353
  });
4354
4354
  }
4355
- var transformObjToSnakeCase, submitAddress, requestValidators, responseValidators, makeRpcRequest;
4355
+ var transformObjToSnakeCase, submitAddress, rpcResult, requestValidators, responseValidators, makeRpcRequest;
4356
4356
  var init_broker = __esm({
4357
4357
  "../shared/src/broker.ts"() {
4358
4358
  init_lib();
@@ -4378,6 +4378,18 @@ var init_broker = __esm({
4378
4378
  }
4379
4379
  return address;
4380
4380
  }, "submitAddress");
4381
+ rpcResult = z.union([
4382
+ z.object({
4383
+ error: z.object({
4384
+ code: z.number().optional(),
4385
+ message: z.string().optional(),
4386
+ data: z.unknown().optional()
4387
+ })
4388
+ }),
4389
+ z.object({
4390
+ result: z.unknown()
4391
+ })
4392
+ ]);
4381
4393
  requestValidators = {
4382
4394
  requestSwapDepositAddress: z.tuple([
4383
4395
  chainflipAsset.transform(transformAsset),
@@ -4428,13 +4440,17 @@ var init_broker = __esm({
4428
4440
  method: `broker_${method}`,
4429
4441
  params: requestValidators[method].parse(params)
4430
4442
  });
4431
- return responseValidators[method].parse(res.data.result);
4443
+ const result = rpcResult.parse(res.data);
4444
+ if ("error" in result) {
4445
+ throw new Error(`Broker responded with error code ${result.error.code}: ${result.error.message}`);
4446
+ }
4447
+ return responseValidators[method].parse(result.result);
4432
4448
  }, "makeRpcRequest");
4433
4449
  __name(requestSwapDepositAddress, "requestSwapDepositAddress");
4434
4450
  }
4435
4451
  });
4436
4452
 
4437
- // ../../node_modules/.pnpm/@trpc+server@10.40.0/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
4453
+ // ../../node_modules/.pnpm/@trpc+server@10.41.0/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
4438
4454
  function identity(x) {
4439
4455
  return x;
4440
4456
  }
@@ -4513,7 +4529,7 @@ function observable(subscribe) {
4513
4529
  }
4514
4530
  __name(observable, "observable");
4515
4531
 
4516
- // ../../node_modules/.pnpm/@trpc+server@10.40.0/node_modules/@trpc/server/dist/observable/index.mjs
4532
+ // ../../node_modules/.pnpm/@trpc+server@10.41.0/node_modules/@trpc/server/dist/observable/index.mjs
4517
4533
  function share(_opts) {
4518
4534
  return (originalObserver) => {
4519
4535
  let refCount = 0;
@@ -4618,7 +4634,7 @@ function observableToPromise(observable2) {
4618
4634
  }
4619
4635
  __name(observableToPromise, "observableToPromise");
4620
4636
 
4621
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
4637
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
4622
4638
  function createChain(opts) {
4623
4639
  return observable((observer) => {
4624
4640
  function execute(index = 0, op = opts.op) {
@@ -4642,7 +4658,7 @@ function createChain(opts) {
4642
4658
  }
4643
4659
  __name(createChain, "createChain");
4644
4660
 
4645
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
4661
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
4646
4662
  function isObject(value) {
4647
4663
  return !!value && !Array.isArray(value) && typeof value === "object";
4648
4664
  }
@@ -4695,7 +4711,7 @@ function transformResult(response, runtime) {
4695
4711
  }
4696
4712
  __name(transformResult, "transformResult");
4697
4713
 
4698
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs
4714
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs
4699
4715
  function isTRPCClientError(cause) {
4700
4716
  return cause instanceof TRPCClientError || /**
4701
4717
  * @deprecated
@@ -4753,7 +4769,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
4753
4769
  __name(_TRPCClientError, "TRPCClientError");
4754
4770
  var TRPCClientError = _TRPCClientError;
4755
4771
 
4756
- // ../../node_modules/.pnpm/@trpc+server@10.40.0/node_modules/@trpc/server/dist/codes-c924c3db.mjs
4772
+ // ../../node_modules/.pnpm/@trpc+server@10.41.0/node_modules/@trpc/server/dist/codes-c924c3db.mjs
4757
4773
  function invert(obj) {
4758
4774
  const newObj = /* @__PURE__ */ Object.create(null);
4759
4775
  for (const key in obj) {
@@ -4791,7 +4807,7 @@ var TRPC_ERROR_CODES_BY_KEY = {
4791
4807
  };
4792
4808
  invert(TRPC_ERROR_CODES_BY_KEY);
4793
4809
 
4794
- // ../../node_modules/.pnpm/@trpc+server@10.40.0/node_modules/@trpc/server/dist/index-f91d720c.mjs
4810
+ // ../../node_modules/.pnpm/@trpc+server@10.41.0/node_modules/@trpc/server/dist/index-f91d720c.mjs
4795
4811
  invert(TRPC_ERROR_CODES_BY_KEY);
4796
4812
  var noop = /* @__PURE__ */ __name(() => {
4797
4813
  }, "noop");
@@ -4829,7 +4845,7 @@ var createFlatProxy = /* @__PURE__ */ __name((callback) => {
4829
4845
  });
4830
4846
  }, "createFlatProxy");
4831
4847
 
4832
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs
4848
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs
4833
4849
  var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
4834
4850
  function getFetch(customFetchImpl) {
4835
4851
  if (customFetchImpl) {
@@ -4973,7 +4989,7 @@ function httpRequest(opts) {
4973
4989
  }
4974
4990
  __name(httpRequest, "httpRequest");
4975
4991
 
4976
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/httpBatchLink-204206a5.mjs
4992
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/httpBatchLink-204206a5.mjs
4977
4993
  var throwFatalError = /* @__PURE__ */ __name(() => {
4978
4994
  throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
4979
4995
  }, "throwFatalError");
@@ -5203,7 +5219,7 @@ var batchRequester = /* @__PURE__ */ __name((requesterOpts) => {
5203
5219
  }, "batchRequester");
5204
5220
  var httpBatchLink = createHTTPBatchLink(batchRequester);
5205
5221
 
5206
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/links/httpLink.mjs
5222
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/links/httpLink.mjs
5207
5223
  function httpLinkFactory(factoryOpts) {
5208
5224
  return (opts) => {
5209
5225
  const resolvedOpts = resolveHTTPLinkOptions(opts);
@@ -5255,7 +5271,7 @@ function httpLinkFactory(factoryOpts) {
5255
5271
  }
5256
5272
  __name(httpLinkFactory, "httpLinkFactory");
5257
5273
 
5258
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/index.mjs
5274
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/index.mjs
5259
5275
  var _TRPCUntypedClient = class _TRPCUntypedClient {
5260
5276
  $request({ type, input, path, context = {} }) {
5261
5277
  const chain$ = createChain({
package/dist/swap.mjs CHANGED
@@ -5,7 +5,7 @@ export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, asset
5
5
  import { decodeAddress } from '@polkadot/util-crypto';
6
6
  import axios from 'axios';
7
7
 
8
- // ../../node_modules/.pnpm/@trpc+server@10.40.0/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
8
+ // ../../node_modules/.pnpm/@trpc+server@10.41.0/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
9
9
  function identity(x) {
10
10
  return x;
11
11
  }
@@ -84,7 +84,7 @@ function observable(subscribe) {
84
84
  }
85
85
  __name(observable, "observable");
86
86
 
87
- // ../../node_modules/.pnpm/@trpc+server@10.40.0/node_modules/@trpc/server/dist/observable/index.mjs
87
+ // ../../node_modules/.pnpm/@trpc+server@10.41.0/node_modules/@trpc/server/dist/observable/index.mjs
88
88
  function share(_opts) {
89
89
  return (originalObserver) => {
90
90
  let refCount = 0;
@@ -189,7 +189,7 @@ function observableToPromise(observable2) {
189
189
  }
190
190
  __name(observableToPromise, "observableToPromise");
191
191
 
192
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
192
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
193
193
  function createChain(opts) {
194
194
  return observable((observer) => {
195
195
  function execute(index = 0, op = opts.op) {
@@ -213,7 +213,7 @@ function createChain(opts) {
213
213
  }
214
214
  __name(createChain, "createChain");
215
215
 
216
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
216
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
217
217
  function isObject(value) {
218
218
  return !!value && !Array.isArray(value) && typeof value === "object";
219
219
  }
@@ -266,7 +266,7 @@ function transformResult(response, runtime) {
266
266
  }
267
267
  __name(transformResult, "transformResult");
268
268
 
269
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs
269
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs
270
270
  function isTRPCClientError(cause) {
271
271
  return cause instanceof TRPCClientError || /**
272
272
  * @deprecated
@@ -324,7 +324,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
324
324
  __name(_TRPCClientError, "TRPCClientError");
325
325
  var TRPCClientError = _TRPCClientError;
326
326
 
327
- // ../../node_modules/.pnpm/@trpc+server@10.40.0/node_modules/@trpc/server/dist/codes-c924c3db.mjs
327
+ // ../../node_modules/.pnpm/@trpc+server@10.41.0/node_modules/@trpc/server/dist/codes-c924c3db.mjs
328
328
  function invert(obj) {
329
329
  const newObj = /* @__PURE__ */ Object.create(null);
330
330
  for (const key in obj) {
@@ -362,7 +362,7 @@ var TRPC_ERROR_CODES_BY_KEY = {
362
362
  };
363
363
  invert(TRPC_ERROR_CODES_BY_KEY);
364
364
 
365
- // ../../node_modules/.pnpm/@trpc+server@10.40.0/node_modules/@trpc/server/dist/index-f91d720c.mjs
365
+ // ../../node_modules/.pnpm/@trpc+server@10.41.0/node_modules/@trpc/server/dist/index-f91d720c.mjs
366
366
  invert(TRPC_ERROR_CODES_BY_KEY);
367
367
  var noop = /* @__PURE__ */ __name(() => {
368
368
  }, "noop");
@@ -400,7 +400,7 @@ var createFlatProxy = /* @__PURE__ */ __name((callback) => {
400
400
  });
401
401
  }, "createFlatProxy");
402
402
 
403
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs
403
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs
404
404
  var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
405
405
  function getFetch(customFetchImpl) {
406
406
  if (customFetchImpl) {
@@ -544,7 +544,7 @@ function httpRequest(opts) {
544
544
  }
545
545
  __name(httpRequest, "httpRequest");
546
546
 
547
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/httpBatchLink-204206a5.mjs
547
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/httpBatchLink-204206a5.mjs
548
548
  var throwFatalError = /* @__PURE__ */ __name(() => {
549
549
  throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
550
550
  }, "throwFatalError");
@@ -774,7 +774,7 @@ var batchRequester = /* @__PURE__ */ __name((requesterOpts) => {
774
774
  }, "batchRequester");
775
775
  var httpBatchLink = createHTTPBatchLink(batchRequester);
776
776
 
777
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/links/httpLink.mjs
777
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/links/httpLink.mjs
778
778
  function httpLinkFactory(factoryOpts) {
779
779
  return (opts) => {
780
780
  const resolvedOpts = resolveHTTPLinkOptions(opts);
@@ -826,7 +826,7 @@ function httpLinkFactory(factoryOpts) {
826
826
  }
827
827
  __name(httpLinkFactory, "httpLinkFactory");
828
828
 
829
- // ../../node_modules/.pnpm/@trpc+client@10.40.0_@trpc+server@10.40.0/node_modules/@trpc/client/dist/index.mjs
829
+ // ../../node_modules/.pnpm/@trpc+client@10.41.0_@trpc+server@10.41.0/node_modules/@trpc/client/dist/index.mjs
830
830
  var _TRPCUntypedClient = class _TRPCUntypedClient {
831
831
  $request({ type, input, path, context = {} }) {
832
832
  const chain$ = createChain({
@@ -2505,7 +2505,7 @@ var _SwapSDK = class _SwapSDK {
2505
2505
  async requestDepositAddress(depositAddressRequest) {
2506
2506
  let response;
2507
2507
  if (this.brokerConfig !== void 0) {
2508
- const { requestSwapDepositAddress } = await import('./broker-FONIQXKG.mjs');
2508
+ const { requestSwapDepositAddress } = await import('./broker-2SDVPKIU.mjs');
2509
2509
  const result = await requestSwapDepositAddress(depositAddressRequest, this.brokerConfig);
2510
2510
  response = {
2511
2511
  id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {