@chainflip/sdk 0.2.10 → 0.2.11
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
|
-
|
|
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,7 +4440,11 @@ var init_broker = __esm({
|
|
|
4428
4440
|
method: `broker_${method}`,
|
|
4429
4441
|
params: requestValidators[method].parse(params)
|
|
4430
4442
|
});
|
|
4431
|
-
|
|
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
|
}
|
package/dist/swap.mjs
CHANGED
|
@@ -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-
|
|
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}`,
|