@chainflip/sdk 1.1.2 → 1.1.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/{broker-IPTE3R72.mjs → broker-TEY2FO74.mjs} +1 -1
- package/dist/{chunk-4PQXI2DE.mjs → chunk-MRYGGECA.mjs} +0 -1
- package/dist/{chunk-Z4OL2TKA.mjs → chunk-QULHGLMY.mjs} +5 -4
- package/dist/funding.js +0 -1
- package/dist/funding.mjs +1 -1
- package/dist/swap.d.mts +1 -2
- package/dist/swap.d.ts +1 -2
- package/dist/swap.js +135 -130
- package/dist/swap.mjs +133 -126
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { chainflipAssetAndChain, numericString, hexString, btcAddress, ccmMetadataSchema, hexStringFromNumber, dotAddress, unsignedInteger } from './chunk-
|
|
1
|
+
import { chainflipAssetAndChain, numericString, hexString, btcAddress, ccmMetadataSchema, hexStringFromNumber, dotAddress, unsignedInteger } from './chunk-QULHGLMY.mjs';
|
|
2
2
|
import { z, __name, Assets, isNotNullish } from './chunk-Q7HQVR3T.mjs';
|
|
3
3
|
import { u8aToHex } from '@polkadot/util';
|
|
4
4
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
@@ -58,7 +58,6 @@ var chainAssetMap = /* @__PURE__ */ __name((parser) => z.object({
|
|
|
58
58
|
var chainAssetNumberMap = chainAssetMap(numberOrHex);
|
|
59
59
|
var chainAssetNumberNullableMap = chainAssetMap(numberOrHex.nullable());
|
|
60
60
|
var swappingEnvironment = z.object({
|
|
61
|
-
minimum_swap_amounts: chainAssetNumberMap,
|
|
62
61
|
maximum_swap_amounts: chainAssetNumberNullableMap
|
|
63
62
|
});
|
|
64
63
|
createRequest("cf_swapping_environment", swappingEnvironment);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __commonJS, __name, __toESM, z, isString, Chains, Assets, assetChains, ChainflipNetworks, assert } from './chunk-Q7HQVR3T.mjs';
|
|
2
|
-
import { hexToU8a } from '@polkadot/util';
|
|
2
|
+
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
|
3
3
|
import { encodeAddress, decodeAddress, base58Decode } from '@polkadot/util-crypto';
|
|
4
4
|
import * as ethers from 'ethers';
|
|
5
5
|
|
|
@@ -499,16 +499,17 @@ var btcAddress = /* @__PURE__ */ __name((network) => {
|
|
|
499
499
|
string.regex(/^bcrt1/).refine(validateBitcoinRegtestAddress)
|
|
500
500
|
]);
|
|
501
501
|
}, "btcAddress");
|
|
502
|
+
var DOT_PREFIX = 0;
|
|
502
503
|
var dotAddress = z.union([
|
|
503
504
|
string,
|
|
504
505
|
hexString
|
|
505
506
|
]).transform((arg) => {
|
|
506
507
|
try {
|
|
507
508
|
if (arg.startsWith("0x")) {
|
|
508
|
-
return encodeAddress(hexToU8a(arg));
|
|
509
|
+
return encodeAddress(hexToU8a(arg), DOT_PREFIX);
|
|
509
510
|
}
|
|
510
|
-
decodeAddress(arg);
|
|
511
|
-
return
|
|
511
|
+
const hex = u8aToHex(decodeAddress(arg));
|
|
512
|
+
return encodeAddress(hex, DOT_PREFIX);
|
|
512
513
|
} catch {
|
|
513
514
|
return null;
|
|
514
515
|
}
|
package/dist/funding.js
CHANGED
|
@@ -4792,7 +4792,6 @@ var chainAssetMap = /* @__PURE__ */ __name((parser) => z.object({
|
|
|
4792
4792
|
var chainAssetNumberMap = chainAssetMap(numberOrHex);
|
|
4793
4793
|
var chainAssetNumberNullableMap = chainAssetMap(numberOrHex.nullable());
|
|
4794
4794
|
var swappingEnvironment = z.object({
|
|
4795
|
-
minimum_swap_amounts: chainAssetNumberMap,
|
|
4796
4795
|
maximum_swap_amounts: chainAssetNumberNullableMap
|
|
4797
4796
|
});
|
|
4798
4797
|
createRequest("cf_swapping_environment", swappingEnvironment);
|
package/dist/funding.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-
|
|
1
|
+
import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-MRYGGECA.mjs';
|
|
2
2
|
import { __name, __publicField, ChainflipNetworks, Assets, assert } from './chunk-Q7HQVR3T.mjs';
|
|
3
3
|
|
|
4
4
|
// ../shared/src/stateChainGateway/utils.ts
|
package/dist/swap.d.mts
CHANGED
|
@@ -485,7 +485,7 @@ type SwapStatusResponse = CommonStatusFields & ({
|
|
|
485
485
|
egressScheduledBlockIndex: string;
|
|
486
486
|
feesPaid: SwapFee[];
|
|
487
487
|
} | {
|
|
488
|
-
state: 'BROADCAST_REQUESTED';
|
|
488
|
+
state: 'BROADCAST_REQUESTED' | 'BROADCASTED';
|
|
489
489
|
swapId: string;
|
|
490
490
|
depositAmount: string;
|
|
491
491
|
depositReceivedAt: number;
|
|
@@ -571,7 +571,6 @@ declare class SwapSDK {
|
|
|
571
571
|
getSwapLimits(): Promise<{
|
|
572
572
|
minimumSwapAmounts: ChainAssetMap<bigint>;
|
|
573
573
|
maximumSwapAmounts: ChainAssetMap<bigint | null>;
|
|
574
|
-
minimumDepositAmounts: ChainAssetMap<bigint>;
|
|
575
574
|
}>;
|
|
576
575
|
}
|
|
577
576
|
|
package/dist/swap.d.ts
CHANGED
|
@@ -485,7 +485,7 @@ type SwapStatusResponse = CommonStatusFields & ({
|
|
|
485
485
|
egressScheduledBlockIndex: string;
|
|
486
486
|
feesPaid: SwapFee[];
|
|
487
487
|
} | {
|
|
488
|
-
state: 'BROADCAST_REQUESTED';
|
|
488
|
+
state: 'BROADCAST_REQUESTED' | 'BROADCASTED';
|
|
489
489
|
swapId: string;
|
|
490
490
|
depositAmount: string;
|
|
491
491
|
depositReceivedAt: number;
|
|
@@ -571,7 +571,6 @@ declare class SwapSDK {
|
|
|
571
571
|
getSwapLimits(): Promise<{
|
|
572
572
|
minimumSwapAmounts: ChainAssetMap<bigint>;
|
|
573
573
|
maximumSwapAmounts: ChainAssetMap<bigint | null>;
|
|
574
|
-
minimumDepositAmounts: ChainAssetMap<bigint>;
|
|
575
574
|
}>;
|
|
576
575
|
}
|
|
577
576
|
|
package/dist/swap.js
CHANGED
|
@@ -4485,7 +4485,7 @@ var init_addressValidation = __esm({
|
|
|
4485
4485
|
validateBitcoinRegtestAddress = /* @__PURE__ */ __name((address) => validateBitcoinAddress(address, "regtest"), "validateBitcoinRegtestAddress");
|
|
4486
4486
|
}
|
|
4487
4487
|
});
|
|
4488
|
-
var safeStringify, errorMap2, string, numericString, hexString, hexStringWithMaxByteSize, hexStringFromNumber, btcAddress, dotAddress, ethereumAddress, u128, unsignedInteger, transformAsset, chainflipChain, chainflipAsset, chainflipAssetAndChain;
|
|
4488
|
+
var safeStringify, errorMap2, string, numericString, hexString, hexStringWithMaxByteSize, hexStringFromNumber, btcAddress, DOT_PREFIX, dotAddress, ethereumAddress, u128, unsignedInteger, transformAsset, chainflipChain, chainflipAsset, chainflipAssetAndChain;
|
|
4489
4489
|
var init_parsers = __esm({
|
|
4490
4490
|
"../shared/src/parsers.ts"() {
|
|
4491
4491
|
init_lib();
|
|
@@ -4518,16 +4518,17 @@ var init_parsers = __esm({
|
|
|
4518
4518
|
string.regex(/^bcrt1/).refine(validateBitcoinRegtestAddress)
|
|
4519
4519
|
]);
|
|
4520
4520
|
}, "btcAddress");
|
|
4521
|
+
DOT_PREFIX = 0;
|
|
4521
4522
|
dotAddress = z.union([
|
|
4522
4523
|
string,
|
|
4523
4524
|
hexString
|
|
4524
4525
|
]).transform((arg) => {
|
|
4525
4526
|
try {
|
|
4526
4527
|
if (arg.startsWith("0x")) {
|
|
4527
|
-
return utilCrypto.encodeAddress(util$1.hexToU8a(arg));
|
|
4528
|
+
return utilCrypto.encodeAddress(util$1.hexToU8a(arg), DOT_PREFIX);
|
|
4528
4529
|
}
|
|
4529
|
-
utilCrypto.decodeAddress(arg);
|
|
4530
|
-
return
|
|
4530
|
+
const hex = util$1.u8aToHex(utilCrypto.decodeAddress(arg));
|
|
4531
|
+
return utilCrypto.encodeAddress(hex, DOT_PREFIX);
|
|
4531
4532
|
} catch {
|
|
4532
4533
|
return null;
|
|
4533
4534
|
}
|
|
@@ -4752,7 +4753,7 @@ var init_broker = __esm({
|
|
|
4752
4753
|
}
|
|
4753
4754
|
});
|
|
4754
4755
|
|
|
4755
|
-
// ../../node_modules/.pnpm/@trpc+server@10.
|
|
4756
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.0/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
|
|
4756
4757
|
function identity(x) {
|
|
4757
4758
|
return x;
|
|
4758
4759
|
}
|
|
@@ -4831,7 +4832,7 @@ function observable(subscribe) {
|
|
|
4831
4832
|
}
|
|
4832
4833
|
__name(observable, "observable");
|
|
4833
4834
|
|
|
4834
|
-
// ../../node_modules/.pnpm/@trpc+server@10.
|
|
4835
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.0/node_modules/@trpc/server/dist/observable/index.mjs
|
|
4835
4836
|
function share(_opts) {
|
|
4836
4837
|
return (originalObserver) => {
|
|
4837
4838
|
let refCount = 0;
|
|
@@ -4936,7 +4937,7 @@ function observableToPromise(observable2) {
|
|
|
4936
4937
|
}
|
|
4937
4938
|
__name(observableToPromise, "observableToPromise");
|
|
4938
4939
|
|
|
4939
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
4940
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
|
|
4940
4941
|
function createChain(opts) {
|
|
4941
4942
|
return observable((observer) => {
|
|
4942
4943
|
function execute(index = 0, op = opts.op) {
|
|
@@ -4960,11 +4961,118 @@ function createChain(opts) {
|
|
|
4960
4961
|
}
|
|
4961
4962
|
__name(createChain, "createChain");
|
|
4962
4963
|
|
|
4963
|
-
// ../../node_modules/.pnpm/@trpc+
|
|
4964
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.0/node_modules/@trpc/server/dist/codes-c924c3db.mjs
|
|
4965
|
+
function invert(obj) {
|
|
4966
|
+
const newObj = /* @__PURE__ */ Object.create(null);
|
|
4967
|
+
for (const key in obj) {
|
|
4968
|
+
const v = obj[key];
|
|
4969
|
+
newObj[v] = key;
|
|
4970
|
+
}
|
|
4971
|
+
return newObj;
|
|
4972
|
+
}
|
|
4973
|
+
__name(invert, "invert");
|
|
4974
|
+
var TRPC_ERROR_CODES_BY_KEY = {
|
|
4975
|
+
/**
|
|
4976
|
+
* Invalid JSON was received by the server.
|
|
4977
|
+
* An error occurred on the server while parsing the JSON text.
|
|
4978
|
+
*/
|
|
4979
|
+
PARSE_ERROR: -32700,
|
|
4980
|
+
/**
|
|
4981
|
+
* The JSON sent is not a valid Request object.
|
|
4982
|
+
*/
|
|
4983
|
+
BAD_REQUEST: -32600,
|
|
4984
|
+
// Internal JSON-RPC error
|
|
4985
|
+
INTERNAL_SERVER_ERROR: -32603,
|
|
4986
|
+
NOT_IMPLEMENTED: -32603,
|
|
4987
|
+
// Implementation specific errors
|
|
4988
|
+
UNAUTHORIZED: -32001,
|
|
4989
|
+
FORBIDDEN: -32003,
|
|
4990
|
+
NOT_FOUND: -32004,
|
|
4991
|
+
METHOD_NOT_SUPPORTED: -32005,
|
|
4992
|
+
TIMEOUT: -32008,
|
|
4993
|
+
CONFLICT: -32009,
|
|
4994
|
+
PRECONDITION_FAILED: -32012,
|
|
4995
|
+
PAYLOAD_TOO_LARGE: -32013,
|
|
4996
|
+
UNPROCESSABLE_CONTENT: -32022,
|
|
4997
|
+
TOO_MANY_REQUESTS: -32029,
|
|
4998
|
+
CLIENT_CLOSED_REQUEST: -32099
|
|
4999
|
+
};
|
|
5000
|
+
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
5001
|
+
|
|
5002
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.0/node_modules/@trpc/server/dist/index-f91d720c.mjs
|
|
5003
|
+
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
5004
|
+
var noop = /* @__PURE__ */ __name(() => {
|
|
5005
|
+
}, "noop");
|
|
5006
|
+
function createInnerProxy(callback, path) {
|
|
5007
|
+
const proxy = new Proxy(noop, {
|
|
5008
|
+
get(_obj, key) {
|
|
5009
|
+
if (typeof key !== "string" || key === "then") {
|
|
5010
|
+
return void 0;
|
|
5011
|
+
}
|
|
5012
|
+
return createInnerProxy(callback, [
|
|
5013
|
+
...path,
|
|
5014
|
+
key
|
|
5015
|
+
]);
|
|
5016
|
+
},
|
|
5017
|
+
apply(_1, _2, args) {
|
|
5018
|
+
const isApply = path[path.length - 1] === "apply";
|
|
5019
|
+
return callback({
|
|
5020
|
+
args: isApply ? args.length >= 2 ? args[1] : [] : args,
|
|
5021
|
+
path: isApply ? path.slice(0, -1) : path
|
|
5022
|
+
});
|
|
5023
|
+
}
|
|
5024
|
+
});
|
|
5025
|
+
return proxy;
|
|
5026
|
+
}
|
|
5027
|
+
__name(createInnerProxy, "createInnerProxy");
|
|
5028
|
+
var createRecursiveProxy = /* @__PURE__ */ __name((callback) => createInnerProxy(callback, []), "createRecursiveProxy");
|
|
5029
|
+
var createFlatProxy = /* @__PURE__ */ __name((callback) => {
|
|
5030
|
+
return new Proxy(noop, {
|
|
5031
|
+
get(_obj, name) {
|
|
5032
|
+
if (typeof name !== "string" || name === "then") {
|
|
5033
|
+
return void 0;
|
|
5034
|
+
}
|
|
5035
|
+
return callback(name);
|
|
5036
|
+
}
|
|
5037
|
+
});
|
|
5038
|
+
}, "createFlatProxy");
|
|
5039
|
+
|
|
5040
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.0/node_modules/@trpc/server/dist/getCauseFromUnknown-2d66414a.mjs
|
|
4964
5041
|
function isObject(value) {
|
|
4965
5042
|
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
4966
5043
|
}
|
|
4967
5044
|
__name(isObject, "isObject");
|
|
5045
|
+
var _UnknownCauseError = class _UnknownCauseError extends Error {
|
|
5046
|
+
};
|
|
5047
|
+
__name(_UnknownCauseError, "UnknownCauseError");
|
|
5048
|
+
var UnknownCauseError = _UnknownCauseError;
|
|
5049
|
+
function getCauseFromUnknown(cause) {
|
|
5050
|
+
if (cause instanceof Error) {
|
|
5051
|
+
return cause;
|
|
5052
|
+
}
|
|
5053
|
+
const type = typeof cause;
|
|
5054
|
+
if (type === "undefined" || type === "function" || cause === null) {
|
|
5055
|
+
return void 0;
|
|
5056
|
+
}
|
|
5057
|
+
if (type !== "object") {
|
|
5058
|
+
return new Error(String(cause));
|
|
5059
|
+
}
|
|
5060
|
+
if (isObject(cause)) {
|
|
5061
|
+
const err = new UnknownCauseError();
|
|
5062
|
+
for (const key in cause) {
|
|
5063
|
+
err[key] = cause[key];
|
|
5064
|
+
}
|
|
5065
|
+
return err;
|
|
5066
|
+
}
|
|
5067
|
+
return void 0;
|
|
5068
|
+
}
|
|
5069
|
+
__name(getCauseFromUnknown, "getCauseFromUnknown");
|
|
5070
|
+
|
|
5071
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
|
|
5072
|
+
function isObject2(value) {
|
|
5073
|
+
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
5074
|
+
}
|
|
5075
|
+
__name(isObject2, "isObject");
|
|
4968
5076
|
function transformResultInner(response, runtime) {
|
|
4969
5077
|
if ("error" in response) {
|
|
4970
5078
|
const error = runtime.transformer.deserialize(response.error);
|
|
@@ -5003,17 +5111,17 @@ function transformResult(response, runtime) {
|
|
|
5003
5111
|
} catch (err) {
|
|
5004
5112
|
throw new TransformResultError();
|
|
5005
5113
|
}
|
|
5006
|
-
if (!result.ok && (!
|
|
5114
|
+
if (!result.ok && (!isObject2(result.error.error) || typeof result.error.error.code !== "number")) {
|
|
5007
5115
|
throw new TransformResultError();
|
|
5008
5116
|
}
|
|
5009
|
-
if (result.ok && !
|
|
5117
|
+
if (result.ok && !isObject2(result.result)) {
|
|
5010
5118
|
throw new TransformResultError();
|
|
5011
5119
|
}
|
|
5012
5120
|
return result;
|
|
5013
5121
|
}
|
|
5014
5122
|
__name(transformResult, "transformResult");
|
|
5015
5123
|
|
|
5016
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
5124
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/TRPCClientError-38f9a32a.mjs
|
|
5017
5125
|
function isTRPCClientError(cause) {
|
|
5018
5126
|
return cause instanceof TRPCClientError || /**
|
|
5019
5127
|
* @deprecated
|
|
@@ -5023,7 +5131,7 @@ function isTRPCClientError(cause) {
|
|
|
5023
5131
|
}
|
|
5024
5132
|
__name(isTRPCClientError, "isTRPCClientError");
|
|
5025
5133
|
function isTRPCErrorResponse(obj) {
|
|
5026
|
-
return
|
|
5134
|
+
return isObject2(obj) && isObject2(obj.error) && typeof obj.error.code === "number" && typeof obj.error.message === "string";
|
|
5027
5135
|
}
|
|
5028
5136
|
__name(isTRPCErrorResponse, "isTRPCErrorResponse");
|
|
5029
5137
|
var _TRPCClientError = class _TRPCClientError extends Error {
|
|
@@ -5052,7 +5160,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
|
|
|
5052
5160
|
}
|
|
5053
5161
|
return new _TRPCClientError(cause.message, {
|
|
5054
5162
|
...opts,
|
|
5055
|
-
cause
|
|
5163
|
+
cause: getCauseFromUnknown(cause)
|
|
5056
5164
|
});
|
|
5057
5165
|
}
|
|
5058
5166
|
constructor(message, opts) {
|
|
@@ -5071,83 +5179,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
|
|
|
5071
5179
|
__name(_TRPCClientError, "TRPCClientError");
|
|
5072
5180
|
var TRPCClientError = _TRPCClientError;
|
|
5073
5181
|
|
|
5074
|
-
// ../../node_modules/.pnpm/@trpc+server@10.
|
|
5075
|
-
function invert(obj) {
|
|
5076
|
-
const newObj = /* @__PURE__ */ Object.create(null);
|
|
5077
|
-
for (const key in obj) {
|
|
5078
|
-
const v = obj[key];
|
|
5079
|
-
newObj[v] = key;
|
|
5080
|
-
}
|
|
5081
|
-
return newObj;
|
|
5082
|
-
}
|
|
5083
|
-
__name(invert, "invert");
|
|
5084
|
-
var TRPC_ERROR_CODES_BY_KEY = {
|
|
5085
|
-
/**
|
|
5086
|
-
* Invalid JSON was received by the server.
|
|
5087
|
-
* An error occurred on the server while parsing the JSON text.
|
|
5088
|
-
*/
|
|
5089
|
-
PARSE_ERROR: -32700,
|
|
5090
|
-
/**
|
|
5091
|
-
* The JSON sent is not a valid Request object.
|
|
5092
|
-
*/
|
|
5093
|
-
BAD_REQUEST: -32600,
|
|
5094
|
-
// Internal JSON-RPC error
|
|
5095
|
-
INTERNAL_SERVER_ERROR: -32603,
|
|
5096
|
-
NOT_IMPLEMENTED: -32603,
|
|
5097
|
-
// Implementation specific errors
|
|
5098
|
-
UNAUTHORIZED: -32001,
|
|
5099
|
-
FORBIDDEN: -32003,
|
|
5100
|
-
NOT_FOUND: -32004,
|
|
5101
|
-
METHOD_NOT_SUPPORTED: -32005,
|
|
5102
|
-
TIMEOUT: -32008,
|
|
5103
|
-
CONFLICT: -32009,
|
|
5104
|
-
PRECONDITION_FAILED: -32012,
|
|
5105
|
-
PAYLOAD_TOO_LARGE: -32013,
|
|
5106
|
-
UNPROCESSABLE_CONTENT: -32022,
|
|
5107
|
-
TOO_MANY_REQUESTS: -32029,
|
|
5108
|
-
CLIENT_CLOSED_REQUEST: -32099
|
|
5109
|
-
};
|
|
5110
|
-
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
5111
|
-
|
|
5112
|
-
// ../../node_modules/.pnpm/@trpc+server@10.44.1/node_modules/@trpc/server/dist/index-f91d720c.mjs
|
|
5113
|
-
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
5114
|
-
var noop = /* @__PURE__ */ __name(() => {
|
|
5115
|
-
}, "noop");
|
|
5116
|
-
function createInnerProxy(callback, path) {
|
|
5117
|
-
const proxy = new Proxy(noop, {
|
|
5118
|
-
get(_obj, key) {
|
|
5119
|
-
if (typeof key !== "string" || key === "then") {
|
|
5120
|
-
return void 0;
|
|
5121
|
-
}
|
|
5122
|
-
return createInnerProxy(callback, [
|
|
5123
|
-
...path,
|
|
5124
|
-
key
|
|
5125
|
-
]);
|
|
5126
|
-
},
|
|
5127
|
-
apply(_1, _2, args) {
|
|
5128
|
-
const isApply = path[path.length - 1] === "apply";
|
|
5129
|
-
return callback({
|
|
5130
|
-
args: isApply ? args.length >= 2 ? args[1] : [] : args,
|
|
5131
|
-
path: isApply ? path.slice(0, -1) : path
|
|
5132
|
-
});
|
|
5133
|
-
}
|
|
5134
|
-
});
|
|
5135
|
-
return proxy;
|
|
5136
|
-
}
|
|
5137
|
-
__name(createInnerProxy, "createInnerProxy");
|
|
5138
|
-
var createRecursiveProxy = /* @__PURE__ */ __name((callback) => createInnerProxy(callback, []), "createRecursiveProxy");
|
|
5139
|
-
var createFlatProxy = /* @__PURE__ */ __name((callback) => {
|
|
5140
|
-
return new Proxy(noop, {
|
|
5141
|
-
get(_obj, name) {
|
|
5142
|
-
if (typeof name !== "string" || name === "then") {
|
|
5143
|
-
return void 0;
|
|
5144
|
-
}
|
|
5145
|
-
return callback(name);
|
|
5146
|
-
}
|
|
5147
|
-
});
|
|
5148
|
-
}, "createFlatProxy");
|
|
5149
|
-
|
|
5150
|
-
// ../../node_modules/.pnpm/@trpc+client@10.44.1_@trpc+server@10.44.1/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs
|
|
5182
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/httpUtils-b9d0cb48.mjs
|
|
5151
5183
|
var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
|
|
5152
5184
|
function getFetch(customFetchImpl) {
|
|
5153
5185
|
if (customFetchImpl) {
|
|
@@ -5291,7 +5323,7 @@ function httpRequest(opts) {
|
|
|
5291
5323
|
}
|
|
5292
5324
|
__name(httpRequest, "httpRequest");
|
|
5293
5325
|
|
|
5294
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
5326
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/httpBatchLink-d0f9eac9.mjs
|
|
5295
5327
|
var throwFatalError = /* @__PURE__ */ __name(() => {
|
|
5296
5328
|
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
|
|
5297
5329
|
}, "throwFatalError");
|
|
@@ -5521,7 +5553,7 @@ var batchRequester = /* @__PURE__ */ __name((requesterOpts) => {
|
|
|
5521
5553
|
}, "batchRequester");
|
|
5522
5554
|
var httpBatchLink = createHTTPBatchLink(batchRequester);
|
|
5523
5555
|
|
|
5524
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
5556
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/links/httpLink.mjs
|
|
5525
5557
|
function httpLinkFactory(factoryOpts) {
|
|
5526
5558
|
return (opts) => {
|
|
5527
5559
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
@@ -5573,7 +5605,7 @@ function httpLinkFactory(factoryOpts) {
|
|
|
5573
5605
|
}
|
|
5574
5606
|
__name(httpLinkFactory, "httpLinkFactory");
|
|
5575
5607
|
|
|
5576
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
5608
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/index.mjs
|
|
5577
5609
|
var _TRPCUntypedClient = class _TRPCUntypedClient {
|
|
5578
5610
|
$request({ type, input, path, context = {} }) {
|
|
5579
5611
|
const chain$ = createChain({
|
|
@@ -6984,7 +7016,6 @@ var chainAssetMap = /* @__PURE__ */ __name((parser) => z.object({
|
|
|
6984
7016
|
var chainAssetNumberMap = chainAssetMap(numberOrHex);
|
|
6985
7017
|
var chainAssetNumberNullableMap = chainAssetMap(numberOrHex.nullable());
|
|
6986
7018
|
var swappingEnvironment = z.object({
|
|
6987
|
-
minimum_swap_amounts: chainAssetNumberMap,
|
|
6988
7019
|
maximum_swap_amounts: chainAssetNumberNullableMap
|
|
6989
7020
|
});
|
|
6990
7021
|
createRequest("cf_swapping_environment", swappingEnvironment);
|
|
@@ -7063,23 +7094,13 @@ createRequest("cf_swap_rate", swapRate);
|
|
|
7063
7094
|
|
|
7064
7095
|
// ../shared/src/rpc/utils.ts
|
|
7065
7096
|
init_enums();
|
|
7066
|
-
|
|
7067
|
-
// ../shared/src/functions.ts
|
|
7068
|
-
var bigintMax = /* @__PURE__ */ __name((...args) => args.reduce((max, current) => current > max ? current : max), "bigintMax");
|
|
7069
|
-
|
|
7070
|
-
// ../shared/src/rpc/utils.ts
|
|
7071
7097
|
var readAssetValue = /* @__PURE__ */ __name((value, asset) => {
|
|
7072
7098
|
assertIsValidAssetAndChain(asset);
|
|
7073
7099
|
const chainMinimums = value[asset.chain];
|
|
7074
7100
|
return chainMinimums[asset.asset];
|
|
7075
7101
|
}, "readAssetValue");
|
|
7076
|
-
var readMinimumSwapAmount = /* @__PURE__ */ __name((env, asset) => {
|
|
7077
|
-
const minimumSwapAmount = readAssetValue(env.swapping.minimumSwapAmounts, asset);
|
|
7078
|
-
const minimumDepositAmount = readAssetValue(env.ingressEgress.minimumDepositAmounts, asset);
|
|
7079
|
-
return bigintMax(minimumSwapAmount, minimumDepositAmount);
|
|
7080
|
-
}, "readMinimumSwapAmount");
|
|
7081
7102
|
var validateSwapAmount = /* @__PURE__ */ __name((env, asset, amount) => {
|
|
7082
|
-
const minimumAmount =
|
|
7103
|
+
const minimumAmount = readAssetValue(env.ingressEgress.minimumDepositAmounts, asset);
|
|
7083
7104
|
if (amount < minimumAmount) {
|
|
7084
7105
|
return {
|
|
7085
7106
|
success: false,
|
|
@@ -8646,10 +8667,7 @@ var eth$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
8646
8667
|
symbol: "ETH",
|
|
8647
8668
|
chainflipId: "ETH",
|
|
8648
8669
|
isMainnet: !isTestnet(network),
|
|
8649
|
-
minimumSwapAmount:
|
|
8650
|
-
chain: "Ethereum",
|
|
8651
|
-
asset: "ETH"
|
|
8652
|
-
}).toString(),
|
|
8670
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.ETH.toString(),
|
|
8653
8671
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Ethereum.ETH?.toString() ?? null
|
|
8654
8672
|
}), "eth$");
|
|
8655
8673
|
var usdc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
@@ -8661,10 +8679,7 @@ var usdc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
8661
8679
|
symbol: "USDC",
|
|
8662
8680
|
chainflipId: "USDC",
|
|
8663
8681
|
isMainnet: !isTestnet(network),
|
|
8664
|
-
minimumSwapAmount:
|
|
8665
|
-
chain: "Ethereum",
|
|
8666
|
-
asset: "USDC"
|
|
8667
|
-
}).toString(),
|
|
8682
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.USDC.toString(),
|
|
8668
8683
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Ethereum.USDC?.toString() ?? null
|
|
8669
8684
|
}), "usdc$");
|
|
8670
8685
|
var flip$ = /* @__PURE__ */ __name((network, env) => ({
|
|
@@ -8676,10 +8691,7 @@ var flip$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
8676
8691
|
symbol: "FLIP",
|
|
8677
8692
|
chainflipId: "FLIP",
|
|
8678
8693
|
isMainnet: !isTestnet(network),
|
|
8679
|
-
minimumSwapAmount:
|
|
8680
|
-
chain: "Ethereum",
|
|
8681
|
-
asset: "FLIP"
|
|
8682
|
-
}).toString(),
|
|
8694
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.FLIP.toString(),
|
|
8683
8695
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Ethereum.FLIP?.toString() ?? null
|
|
8684
8696
|
}), "flip$");
|
|
8685
8697
|
var dot$ = /* @__PURE__ */ __name((network, env) => ({
|
|
@@ -8691,10 +8703,7 @@ var dot$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
8691
8703
|
symbol: "DOT",
|
|
8692
8704
|
chainflipId: "DOT",
|
|
8693
8705
|
isMainnet: !isTestnet(network),
|
|
8694
|
-
minimumSwapAmount:
|
|
8695
|
-
chain: "Polkadot",
|
|
8696
|
-
asset: "DOT"
|
|
8697
|
-
}).toString(),
|
|
8706
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Polkadot.DOT.toString(),
|
|
8698
8707
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Polkadot.DOT?.toString() ?? null
|
|
8699
8708
|
}), "dot$");
|
|
8700
8709
|
var btc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
@@ -8706,10 +8715,7 @@ var btc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
8706
8715
|
symbol: "BTC",
|
|
8707
8716
|
chainflipId: "BTC",
|
|
8708
8717
|
isMainnet: !isTestnet(network),
|
|
8709
|
-
minimumSwapAmount:
|
|
8710
|
-
chain: "Bitcoin",
|
|
8711
|
-
asset: "BTC"
|
|
8712
|
-
}).toString(),
|
|
8718
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Bitcoin.BTC.toString(),
|
|
8713
8719
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Bitcoin.BTC?.toString() ?? null
|
|
8714
8720
|
}), "btc$");
|
|
8715
8721
|
|
|
@@ -8908,11 +8914,10 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8908
8914
|
throw new Error(result.reason);
|
|
8909
8915
|
}
|
|
8910
8916
|
async getSwapLimits() {
|
|
8911
|
-
const { swapping: {
|
|
8917
|
+
const { swapping: { maximumSwapAmounts }, ingressEgress: { minimumDepositAmounts } } = await this.getStateChainEnvironment();
|
|
8912
8918
|
return {
|
|
8913
|
-
minimumSwapAmounts,
|
|
8914
|
-
maximumSwapAmounts
|
|
8915
|
-
minimumDepositAmounts
|
|
8919
|
+
minimumSwapAmounts: minimumDepositAmounts,
|
|
8920
|
+
maximumSwapAmounts
|
|
8916
8921
|
};
|
|
8917
8922
|
}
|
|
8918
8923
|
};
|
|
@@ -8923,7 +8928,7 @@ var SwapSDK = _SwapSDK;
|
|
|
8923
8928
|
init_enums();
|
|
8924
8929
|
/*! Bundled license information:
|
|
8925
8930
|
|
|
8926
|
-
@trpc/client/dist/httpUtils-
|
|
8931
|
+
@trpc/client/dist/httpUtils-b9d0cb48.mjs:
|
|
8927
8932
|
(* istanbul ignore if -- @preserve *)
|
|
8928
8933
|
|
|
8929
8934
|
@trpc/client/dist/links/wsLink.mjs:
|
package/dist/swap.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getEnvironment, getVaultManagerContractAddress, approve, getTokenContractAddress, checkAllowance, Vault__factory, extractOverrides } from './chunk-
|
|
2
|
-
import { numericString, ethereumAddress, dotAddress, ccmMetadataSchema, btcAddress } from './chunk-
|
|
1
|
+
import { getEnvironment, getVaultManagerContractAddress, approve, getTokenContractAddress, checkAllowance, Vault__factory, extractOverrides } from './chunk-MRYGGECA.mjs';
|
|
2
|
+
import { numericString, ethereumAddress, dotAddress, ccmMetadataSchema, btcAddress } from './chunk-QULHGLMY.mjs';
|
|
3
3
|
import { __name, z, Chains, Assets, ChainflipNetworks, __publicField, assert, assertIsValidAssetAndChain, isTokenCall, isTokenSwap, chainContractIds, assetContractIds, assetDecimals, isTestnet } from './chunk-Q7HQVR3T.mjs';
|
|
4
4
|
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-Q7HQVR3T.mjs';
|
|
5
5
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/.pnpm/@trpc+server@10.
|
|
8
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.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.
|
|
87
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.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.
|
|
192
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.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,11 +213,118 @@ function createChain(opts) {
|
|
|
213
213
|
}
|
|
214
214
|
__name(createChain, "createChain");
|
|
215
215
|
|
|
216
|
-
// ../../node_modules/.pnpm/@trpc+
|
|
216
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.0/node_modules/@trpc/server/dist/codes-c924c3db.mjs
|
|
217
|
+
function invert(obj) {
|
|
218
|
+
const newObj = /* @__PURE__ */ Object.create(null);
|
|
219
|
+
for (const key in obj) {
|
|
220
|
+
const v = obj[key];
|
|
221
|
+
newObj[v] = key;
|
|
222
|
+
}
|
|
223
|
+
return newObj;
|
|
224
|
+
}
|
|
225
|
+
__name(invert, "invert");
|
|
226
|
+
var TRPC_ERROR_CODES_BY_KEY = {
|
|
227
|
+
/**
|
|
228
|
+
* Invalid JSON was received by the server.
|
|
229
|
+
* An error occurred on the server while parsing the JSON text.
|
|
230
|
+
*/
|
|
231
|
+
PARSE_ERROR: -32700,
|
|
232
|
+
/**
|
|
233
|
+
* The JSON sent is not a valid Request object.
|
|
234
|
+
*/
|
|
235
|
+
BAD_REQUEST: -32600,
|
|
236
|
+
// Internal JSON-RPC error
|
|
237
|
+
INTERNAL_SERVER_ERROR: -32603,
|
|
238
|
+
NOT_IMPLEMENTED: -32603,
|
|
239
|
+
// Implementation specific errors
|
|
240
|
+
UNAUTHORIZED: -32001,
|
|
241
|
+
FORBIDDEN: -32003,
|
|
242
|
+
NOT_FOUND: -32004,
|
|
243
|
+
METHOD_NOT_SUPPORTED: -32005,
|
|
244
|
+
TIMEOUT: -32008,
|
|
245
|
+
CONFLICT: -32009,
|
|
246
|
+
PRECONDITION_FAILED: -32012,
|
|
247
|
+
PAYLOAD_TOO_LARGE: -32013,
|
|
248
|
+
UNPROCESSABLE_CONTENT: -32022,
|
|
249
|
+
TOO_MANY_REQUESTS: -32029,
|
|
250
|
+
CLIENT_CLOSED_REQUEST: -32099
|
|
251
|
+
};
|
|
252
|
+
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
253
|
+
|
|
254
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.0/node_modules/@trpc/server/dist/index-f91d720c.mjs
|
|
255
|
+
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
256
|
+
var noop = /* @__PURE__ */ __name(() => {
|
|
257
|
+
}, "noop");
|
|
258
|
+
function createInnerProxy(callback, path) {
|
|
259
|
+
const proxy = new Proxy(noop, {
|
|
260
|
+
get(_obj, key) {
|
|
261
|
+
if (typeof key !== "string" || key === "then") {
|
|
262
|
+
return void 0;
|
|
263
|
+
}
|
|
264
|
+
return createInnerProxy(callback, [
|
|
265
|
+
...path,
|
|
266
|
+
key
|
|
267
|
+
]);
|
|
268
|
+
},
|
|
269
|
+
apply(_1, _2, args) {
|
|
270
|
+
const isApply = path[path.length - 1] === "apply";
|
|
271
|
+
return callback({
|
|
272
|
+
args: isApply ? args.length >= 2 ? args[1] : [] : args,
|
|
273
|
+
path: isApply ? path.slice(0, -1) : path
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
return proxy;
|
|
278
|
+
}
|
|
279
|
+
__name(createInnerProxy, "createInnerProxy");
|
|
280
|
+
var createRecursiveProxy = /* @__PURE__ */ __name((callback) => createInnerProxy(callback, []), "createRecursiveProxy");
|
|
281
|
+
var createFlatProxy = /* @__PURE__ */ __name((callback) => {
|
|
282
|
+
return new Proxy(noop, {
|
|
283
|
+
get(_obj, name) {
|
|
284
|
+
if (typeof name !== "string" || name === "then") {
|
|
285
|
+
return void 0;
|
|
286
|
+
}
|
|
287
|
+
return callback(name);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}, "createFlatProxy");
|
|
291
|
+
|
|
292
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.0/node_modules/@trpc/server/dist/getCauseFromUnknown-2d66414a.mjs
|
|
217
293
|
function isObject(value) {
|
|
218
294
|
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
219
295
|
}
|
|
220
296
|
__name(isObject, "isObject");
|
|
297
|
+
var _UnknownCauseError = class _UnknownCauseError extends Error {
|
|
298
|
+
};
|
|
299
|
+
__name(_UnknownCauseError, "UnknownCauseError");
|
|
300
|
+
var UnknownCauseError = _UnknownCauseError;
|
|
301
|
+
function getCauseFromUnknown(cause) {
|
|
302
|
+
if (cause instanceof Error) {
|
|
303
|
+
return cause;
|
|
304
|
+
}
|
|
305
|
+
const type = typeof cause;
|
|
306
|
+
if (type === "undefined" || type === "function" || cause === null) {
|
|
307
|
+
return void 0;
|
|
308
|
+
}
|
|
309
|
+
if (type !== "object") {
|
|
310
|
+
return new Error(String(cause));
|
|
311
|
+
}
|
|
312
|
+
if (isObject(cause)) {
|
|
313
|
+
const err = new UnknownCauseError();
|
|
314
|
+
for (const key in cause) {
|
|
315
|
+
err[key] = cause[key];
|
|
316
|
+
}
|
|
317
|
+
return err;
|
|
318
|
+
}
|
|
319
|
+
return void 0;
|
|
320
|
+
}
|
|
321
|
+
__name(getCauseFromUnknown, "getCauseFromUnknown");
|
|
322
|
+
|
|
323
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
|
|
324
|
+
function isObject2(value) {
|
|
325
|
+
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
326
|
+
}
|
|
327
|
+
__name(isObject2, "isObject");
|
|
221
328
|
function transformResultInner(response, runtime) {
|
|
222
329
|
if ("error" in response) {
|
|
223
330
|
const error = runtime.transformer.deserialize(response.error);
|
|
@@ -256,17 +363,17 @@ function transformResult(response, runtime) {
|
|
|
256
363
|
} catch (err) {
|
|
257
364
|
throw new TransformResultError();
|
|
258
365
|
}
|
|
259
|
-
if (!result.ok && (!
|
|
366
|
+
if (!result.ok && (!isObject2(result.error.error) || typeof result.error.error.code !== "number")) {
|
|
260
367
|
throw new TransformResultError();
|
|
261
368
|
}
|
|
262
|
-
if (result.ok && !
|
|
369
|
+
if (result.ok && !isObject2(result.result)) {
|
|
263
370
|
throw new TransformResultError();
|
|
264
371
|
}
|
|
265
372
|
return result;
|
|
266
373
|
}
|
|
267
374
|
__name(transformResult, "transformResult");
|
|
268
375
|
|
|
269
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
376
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/TRPCClientError-38f9a32a.mjs
|
|
270
377
|
function isTRPCClientError(cause) {
|
|
271
378
|
return cause instanceof TRPCClientError || /**
|
|
272
379
|
* @deprecated
|
|
@@ -276,7 +383,7 @@ function isTRPCClientError(cause) {
|
|
|
276
383
|
}
|
|
277
384
|
__name(isTRPCClientError, "isTRPCClientError");
|
|
278
385
|
function isTRPCErrorResponse(obj) {
|
|
279
|
-
return
|
|
386
|
+
return isObject2(obj) && isObject2(obj.error) && typeof obj.error.code === "number" && typeof obj.error.message === "string";
|
|
280
387
|
}
|
|
281
388
|
__name(isTRPCErrorResponse, "isTRPCErrorResponse");
|
|
282
389
|
var _TRPCClientError = class _TRPCClientError extends Error {
|
|
@@ -305,7 +412,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
|
|
|
305
412
|
}
|
|
306
413
|
return new _TRPCClientError(cause.message, {
|
|
307
414
|
...opts,
|
|
308
|
-
cause
|
|
415
|
+
cause: getCauseFromUnknown(cause)
|
|
309
416
|
});
|
|
310
417
|
}
|
|
311
418
|
constructor(message, opts) {
|
|
@@ -324,83 +431,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
|
|
|
324
431
|
__name(_TRPCClientError, "TRPCClientError");
|
|
325
432
|
var TRPCClientError = _TRPCClientError;
|
|
326
433
|
|
|
327
|
-
// ../../node_modules/.pnpm/@trpc+server@10.
|
|
328
|
-
function invert(obj) {
|
|
329
|
-
const newObj = /* @__PURE__ */ Object.create(null);
|
|
330
|
-
for (const key in obj) {
|
|
331
|
-
const v = obj[key];
|
|
332
|
-
newObj[v] = key;
|
|
333
|
-
}
|
|
334
|
-
return newObj;
|
|
335
|
-
}
|
|
336
|
-
__name(invert, "invert");
|
|
337
|
-
var TRPC_ERROR_CODES_BY_KEY = {
|
|
338
|
-
/**
|
|
339
|
-
* Invalid JSON was received by the server.
|
|
340
|
-
* An error occurred on the server while parsing the JSON text.
|
|
341
|
-
*/
|
|
342
|
-
PARSE_ERROR: -32700,
|
|
343
|
-
/**
|
|
344
|
-
* The JSON sent is not a valid Request object.
|
|
345
|
-
*/
|
|
346
|
-
BAD_REQUEST: -32600,
|
|
347
|
-
// Internal JSON-RPC error
|
|
348
|
-
INTERNAL_SERVER_ERROR: -32603,
|
|
349
|
-
NOT_IMPLEMENTED: -32603,
|
|
350
|
-
// Implementation specific errors
|
|
351
|
-
UNAUTHORIZED: -32001,
|
|
352
|
-
FORBIDDEN: -32003,
|
|
353
|
-
NOT_FOUND: -32004,
|
|
354
|
-
METHOD_NOT_SUPPORTED: -32005,
|
|
355
|
-
TIMEOUT: -32008,
|
|
356
|
-
CONFLICT: -32009,
|
|
357
|
-
PRECONDITION_FAILED: -32012,
|
|
358
|
-
PAYLOAD_TOO_LARGE: -32013,
|
|
359
|
-
UNPROCESSABLE_CONTENT: -32022,
|
|
360
|
-
TOO_MANY_REQUESTS: -32029,
|
|
361
|
-
CLIENT_CLOSED_REQUEST: -32099
|
|
362
|
-
};
|
|
363
|
-
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
364
|
-
|
|
365
|
-
// ../../node_modules/.pnpm/@trpc+server@10.44.1/node_modules/@trpc/server/dist/index-f91d720c.mjs
|
|
366
|
-
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
367
|
-
var noop = /* @__PURE__ */ __name(() => {
|
|
368
|
-
}, "noop");
|
|
369
|
-
function createInnerProxy(callback, path) {
|
|
370
|
-
const proxy = new Proxy(noop, {
|
|
371
|
-
get(_obj, key) {
|
|
372
|
-
if (typeof key !== "string" || key === "then") {
|
|
373
|
-
return void 0;
|
|
374
|
-
}
|
|
375
|
-
return createInnerProxy(callback, [
|
|
376
|
-
...path,
|
|
377
|
-
key
|
|
378
|
-
]);
|
|
379
|
-
},
|
|
380
|
-
apply(_1, _2, args) {
|
|
381
|
-
const isApply = path[path.length - 1] === "apply";
|
|
382
|
-
return callback({
|
|
383
|
-
args: isApply ? args.length >= 2 ? args[1] : [] : args,
|
|
384
|
-
path: isApply ? path.slice(0, -1) : path
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
return proxy;
|
|
389
|
-
}
|
|
390
|
-
__name(createInnerProxy, "createInnerProxy");
|
|
391
|
-
var createRecursiveProxy = /* @__PURE__ */ __name((callback) => createInnerProxy(callback, []), "createRecursiveProxy");
|
|
392
|
-
var createFlatProxy = /* @__PURE__ */ __name((callback) => {
|
|
393
|
-
return new Proxy(noop, {
|
|
394
|
-
get(_obj, name) {
|
|
395
|
-
if (typeof name !== "string" || name === "then") {
|
|
396
|
-
return void 0;
|
|
397
|
-
}
|
|
398
|
-
return callback(name);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
}, "createFlatProxy");
|
|
402
|
-
|
|
403
|
-
// ../../node_modules/.pnpm/@trpc+client@10.44.1_@trpc+server@10.44.1/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs
|
|
434
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/httpUtils-b9d0cb48.mjs
|
|
404
435
|
var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
|
|
405
436
|
function getFetch(customFetchImpl) {
|
|
406
437
|
if (customFetchImpl) {
|
|
@@ -544,7 +575,7 @@ function httpRequest(opts) {
|
|
|
544
575
|
}
|
|
545
576
|
__name(httpRequest, "httpRequest");
|
|
546
577
|
|
|
547
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
578
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/httpBatchLink-d0f9eac9.mjs
|
|
548
579
|
var throwFatalError = /* @__PURE__ */ __name(() => {
|
|
549
580
|
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
|
|
550
581
|
}, "throwFatalError");
|
|
@@ -774,7 +805,7 @@ var batchRequester = /* @__PURE__ */ __name((requesterOpts) => {
|
|
|
774
805
|
}, "batchRequester");
|
|
775
806
|
var httpBatchLink = createHTTPBatchLink(batchRequester);
|
|
776
807
|
|
|
777
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
808
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/links/httpLink.mjs
|
|
778
809
|
function httpLinkFactory(factoryOpts) {
|
|
779
810
|
return (opts) => {
|
|
780
811
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
@@ -826,7 +857,7 @@ function httpLinkFactory(factoryOpts) {
|
|
|
826
857
|
}
|
|
827
858
|
__name(httpLinkFactory, "httpLinkFactory");
|
|
828
859
|
|
|
829
|
-
// ../../node_modules/.pnpm/@trpc+client@10.
|
|
860
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.0_@trpc+server@10.45.0/node_modules/@trpc/client/dist/index.mjs
|
|
830
861
|
var _TRPCUntypedClient = class _TRPCUntypedClient {
|
|
831
862
|
$request({ type, input, path, context = {} }) {
|
|
832
863
|
const chain$ = createChain({
|
|
@@ -2174,22 +2205,14 @@ SuperJSON.registerCustom;
|
|
|
2174
2205
|
SuperJSON.registerSymbol;
|
|
2175
2206
|
SuperJSON.allowErrorProps;
|
|
2176
2207
|
|
|
2177
|
-
// ../shared/src/functions.ts
|
|
2178
|
-
var bigintMax = /* @__PURE__ */ __name((...args) => args.reduce((max, current) => current > max ? current : max), "bigintMax");
|
|
2179
|
-
|
|
2180
2208
|
// ../shared/src/rpc/utils.ts
|
|
2181
2209
|
var readAssetValue = /* @__PURE__ */ __name((value, asset) => {
|
|
2182
2210
|
assertIsValidAssetAndChain(asset);
|
|
2183
2211
|
const chainMinimums = value[asset.chain];
|
|
2184
2212
|
return chainMinimums[asset.asset];
|
|
2185
2213
|
}, "readAssetValue");
|
|
2186
|
-
var readMinimumSwapAmount = /* @__PURE__ */ __name((env, asset) => {
|
|
2187
|
-
const minimumSwapAmount = readAssetValue(env.swapping.minimumSwapAmounts, asset);
|
|
2188
|
-
const minimumDepositAmount = readAssetValue(env.ingressEgress.minimumDepositAmounts, asset);
|
|
2189
|
-
return bigintMax(minimumSwapAmount, minimumDepositAmount);
|
|
2190
|
-
}, "readMinimumSwapAmount");
|
|
2191
2214
|
var validateSwapAmount = /* @__PURE__ */ __name((env, asset, amount) => {
|
|
2192
|
-
const minimumAmount =
|
|
2215
|
+
const minimumAmount = readAssetValue(env.ingressEgress.minimumDepositAmounts, asset);
|
|
2193
2216
|
if (amount < minimumAmount) {
|
|
2194
2217
|
return {
|
|
2195
2218
|
success: false,
|
|
@@ -2371,10 +2394,7 @@ var eth$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
2371
2394
|
symbol: "ETH",
|
|
2372
2395
|
chainflipId: "ETH",
|
|
2373
2396
|
isMainnet: !isTestnet(network),
|
|
2374
|
-
minimumSwapAmount:
|
|
2375
|
-
chain: "Ethereum",
|
|
2376
|
-
asset: "ETH"
|
|
2377
|
-
}).toString(),
|
|
2397
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.ETH.toString(),
|
|
2378
2398
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Ethereum.ETH?.toString() ?? null
|
|
2379
2399
|
}), "eth$");
|
|
2380
2400
|
var usdc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
@@ -2386,10 +2406,7 @@ var usdc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
2386
2406
|
symbol: "USDC",
|
|
2387
2407
|
chainflipId: "USDC",
|
|
2388
2408
|
isMainnet: !isTestnet(network),
|
|
2389
|
-
minimumSwapAmount:
|
|
2390
|
-
chain: "Ethereum",
|
|
2391
|
-
asset: "USDC"
|
|
2392
|
-
}).toString(),
|
|
2409
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.USDC.toString(),
|
|
2393
2410
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Ethereum.USDC?.toString() ?? null
|
|
2394
2411
|
}), "usdc$");
|
|
2395
2412
|
var flip$ = /* @__PURE__ */ __name((network, env) => ({
|
|
@@ -2401,10 +2418,7 @@ var flip$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
2401
2418
|
symbol: "FLIP",
|
|
2402
2419
|
chainflipId: "FLIP",
|
|
2403
2420
|
isMainnet: !isTestnet(network),
|
|
2404
|
-
minimumSwapAmount:
|
|
2405
|
-
chain: "Ethereum",
|
|
2406
|
-
asset: "FLIP"
|
|
2407
|
-
}).toString(),
|
|
2421
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.FLIP.toString(),
|
|
2408
2422
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Ethereum.FLIP?.toString() ?? null
|
|
2409
2423
|
}), "flip$");
|
|
2410
2424
|
var dot$ = /* @__PURE__ */ __name((network, env) => ({
|
|
@@ -2416,10 +2430,7 @@ var dot$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
2416
2430
|
symbol: "DOT",
|
|
2417
2431
|
chainflipId: "DOT",
|
|
2418
2432
|
isMainnet: !isTestnet(network),
|
|
2419
|
-
minimumSwapAmount:
|
|
2420
|
-
chain: "Polkadot",
|
|
2421
|
-
asset: "DOT"
|
|
2422
|
-
}).toString(),
|
|
2433
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Polkadot.DOT.toString(),
|
|
2423
2434
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Polkadot.DOT?.toString() ?? null
|
|
2424
2435
|
}), "dot$");
|
|
2425
2436
|
var btc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
@@ -2431,10 +2442,7 @@ var btc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
|
2431
2442
|
symbol: "BTC",
|
|
2432
2443
|
chainflipId: "BTC",
|
|
2433
2444
|
isMainnet: !isTestnet(network),
|
|
2434
|
-
minimumSwapAmount:
|
|
2435
|
-
chain: "Bitcoin",
|
|
2436
|
-
asset: "BTC"
|
|
2437
|
-
}).toString(),
|
|
2445
|
+
minimumSwapAmount: env.ingressEgress.minimumDepositAmounts.Bitcoin.BTC.toString(),
|
|
2438
2446
|
maximumSwapAmount: env.swapping.maximumSwapAmounts.Bitcoin.BTC?.toString() ?? null
|
|
2439
2447
|
}), "btc$");
|
|
2440
2448
|
|
|
@@ -2581,7 +2589,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2581
2589
|
}, BigInt(amount));
|
|
2582
2590
|
let response;
|
|
2583
2591
|
if (this.brokerConfig !== void 0) {
|
|
2584
|
-
const { requestSwapDepositAddress } = await import('./broker-
|
|
2592
|
+
const { requestSwapDepositAddress } = await import('./broker-TEY2FO74.mjs');
|
|
2585
2593
|
const result = await requestSwapDepositAddress(depositAddressRequest, this.brokerConfig, this.network);
|
|
2586
2594
|
response = {
|
|
2587
2595
|
id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
|
|
@@ -2632,11 +2640,10 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2632
2640
|
throw new Error(result.reason);
|
|
2633
2641
|
}
|
|
2634
2642
|
async getSwapLimits() {
|
|
2635
|
-
const { swapping: {
|
|
2643
|
+
const { swapping: { maximumSwapAmounts }, ingressEgress: { minimumDepositAmounts } } = await this.getStateChainEnvironment();
|
|
2636
2644
|
return {
|
|
2637
|
-
minimumSwapAmounts,
|
|
2638
|
-
maximumSwapAmounts
|
|
2639
|
-
minimumDepositAmounts
|
|
2645
|
+
minimumSwapAmounts: minimumDepositAmounts,
|
|
2646
|
+
maximumSwapAmounts
|
|
2640
2647
|
};
|
|
2641
2648
|
}
|
|
2642
2649
|
};
|
|
@@ -2644,7 +2651,7 @@ __name(_SwapSDK, "SwapSDK");
|
|
|
2644
2651
|
var SwapSDK = _SwapSDK;
|
|
2645
2652
|
/*! Bundled license information:
|
|
2646
2653
|
|
|
2647
|
-
@trpc/client/dist/httpUtils-
|
|
2654
|
+
@trpc/client/dist/httpUtils-b9d0cb48.mjs:
|
|
2648
2655
|
(* istanbul ignore if -- @preserve *)
|
|
2649
2656
|
|
|
2650
2657
|
@trpc/client/dist/links/wsLink.mjs:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@polkadot/util": "^12.6.
|
|
45
|
-
"@polkadot/util-crypto": "^12.6.
|
|
44
|
+
"@polkadot/util": "^12.6.2",
|
|
45
|
+
"@polkadot/util-crypto": "^12.6.2",
|
|
46
46
|
"axios": "^1.6.0",
|
|
47
|
-
"ethers": "6.9.
|
|
47
|
+
"ethers": "6.9.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"tsup": "^8.0.1"
|