@gardenfi/orderbook 2.5.3-beta.0 → 2.5.3-beta.2
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/index.cjs +1 -1
- package/dist/index.js +45 -39
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +35 -20
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +2 -642
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +550 -135
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +92 -32
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +15 -58
- package/dist/index7.cjs +1 -0
- package/dist/index7.js +46 -0
- package/dist/index8.cjs +1 -0
- package/dist/index8.js +28 -0
- package/dist/index9.cjs +1 -0
- package/dist/index9.js +31 -0
- package/dist/src/index.d.ts +7 -4
- package/dist/src/lib/asset.d.ts +0 -210
- package/dist/src/lib/chainAsset/chainAsset.d.ts +10 -11
- package/dist/src/lib/constants/asset.d.ts +1212 -0
- package/dist/src/lib/constants/asset.types.d.ts +37 -0
- package/dist/src/lib/constants/localnetConstants.d.ts +47 -0
- package/dist/src/lib/constants/utils.d.ts +15 -0
- package/dist/src/lib/orderStatus/orderStatus.d.ts +14 -0
- package/dist/src/lib/orderStatus/status.d.ts +0 -0
- package/dist/src/lib/orderbook/orderbook.d.ts +6 -5
- package/dist/src/lib/orderbook/orderbook.types.d.ts +24 -18
- package/dist/src/lib/utils.d.ts +2 -2
- package/package.json +1 -1
- package/dist/src/lib/constants.d.ts +0 -827
package/dist/index5.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={id:1001,name:"Starknet Localnet",nativeCurrency:{name:"Stark Token",symbol:"STRK",decimals:18},rpcUrls:{default:{http:["http://127.0.0.1:8547/"]}},testnet:!0},t={id:31338,name:"Arbitrum Localnet",nativeCurrency:{name:"Ethereum",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["http://localhost:8546/"]}},testnet:!0},a={id:31337,name:"Ethereum Localnet",nativeCurrency:{name:"Ethereum",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["http://localhost:8545/"]}},testnet:!0},s={name:"SOL Solana Localnet",decimals:9,symbol:"SOL",atomicSwapAddress:"primary",tokenAddress:"primary"},n={name:"Bitcoin Regtest",decimals:8,symbol:"BTC",atomicSwapAddress:"primary",tokenAddress:"primary"},c={name:"WBTC Arbitrum Localnet",decimals:8,symbol:"WBTC",atomicSwapAddress:"0x0165878A594ca255338adfa4d48449f69242Eb8F",tokenAddress:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"},o={name:"WBTC Ethereum Localnet",decimals:8,symbol:"WBTC",atomicSwapAddress:"0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",tokenAddress:"0x5FbDB2315678afecb367f032d93F642f64180aa3"},r={name:"STRK Starknet Localnet",decimals:18,symbol:"STRK",atomicSwapAddress:"0x15cf8b127aa850c97ed10de6f8b300cabc4f09232a57e63667af02fdef8a55a",tokenAddress:"0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"},l={name:"ETH Starknet Localnet",decimals:18,symbol:"ETH",atomicSwapAddress:"0x1890470168440bbb9df50988748924a74ea22de10d22a081e458737b9574e75",tokenAddress:"0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"};exports.ArbitrumLocalnet=t;exports.ETHStarknetLocalnetAsset=l;exports.EthereumLocalnet=a;exports.SOLSolanaLocalnetAsset=s;exports.STRKStarknetLocalnetAsset=r;exports.StarknetLocalnet=e;exports.WBTCArbitrumLocalnetAsset=c;exports.WBTCEthereumLocalnetAsset=o;exports.bitcoinRegtestAsset=n;
|
package/dist/index5.js
CHANGED
|
@@ -1,34 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
const e = {
|
|
2
|
+
id: 1001,
|
|
3
|
+
name: "Starknet Localnet",
|
|
4
|
+
nativeCurrency: {
|
|
5
|
+
name: "Stark Token",
|
|
6
|
+
symbol: "STRK",
|
|
7
|
+
decimals: 18
|
|
8
|
+
},
|
|
9
|
+
rpcUrls: {
|
|
10
|
+
default: {
|
|
11
|
+
http: ["http://127.0.0.1:8547/"]
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
testnet: !0
|
|
15
|
+
}, t = {
|
|
16
|
+
id: 31338,
|
|
17
|
+
name: "Arbitrum Localnet",
|
|
18
|
+
nativeCurrency: {
|
|
19
|
+
name: "Ethereum",
|
|
20
|
+
symbol: "ETH",
|
|
21
|
+
decimals: 18
|
|
22
|
+
},
|
|
23
|
+
rpcUrls: {
|
|
24
|
+
default: {
|
|
25
|
+
http: ["http://localhost:8546/"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
testnet: !0
|
|
29
|
+
}, a = {
|
|
30
|
+
id: 31337,
|
|
31
|
+
name: "Ethereum Localnet",
|
|
32
|
+
nativeCurrency: {
|
|
33
|
+
name: "Ethereum",
|
|
34
|
+
symbol: "ETH",
|
|
35
|
+
decimals: 18
|
|
36
|
+
},
|
|
37
|
+
rpcUrls: {
|
|
38
|
+
default: {
|
|
39
|
+
http: ["http://localhost:8545/"]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
testnet: !0
|
|
43
|
+
}, s = {
|
|
44
|
+
name: "SOL Solana Localnet",
|
|
45
|
+
decimals: 9,
|
|
46
|
+
symbol: "SOL",
|
|
47
|
+
atomicSwapAddress: "primary",
|
|
48
|
+
tokenAddress: "primary"
|
|
49
|
+
}, c = {
|
|
50
|
+
name: "Bitcoin Regtest",
|
|
51
|
+
decimals: 8,
|
|
52
|
+
symbol: "BTC",
|
|
53
|
+
atomicSwapAddress: "primary",
|
|
54
|
+
tokenAddress: "primary"
|
|
55
|
+
}, n = {
|
|
56
|
+
name: "WBTC Arbitrum Localnet",
|
|
57
|
+
decimals: 8,
|
|
58
|
+
symbol: "WBTC",
|
|
59
|
+
// atomicSwapAddress: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
|
|
60
|
+
atomicSwapAddress: "0x0165878A594ca255338adfa4d48449f69242Eb8F",
|
|
61
|
+
//present on localnet
|
|
62
|
+
tokenAddress: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
|
|
63
|
+
}, r = {
|
|
64
|
+
name: "WBTC Ethereum Localnet",
|
|
65
|
+
decimals: 8,
|
|
66
|
+
symbol: "WBTC",
|
|
67
|
+
// atomicSwapAddress: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
|
|
68
|
+
atomicSwapAddress: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
|
69
|
+
//present on localnet
|
|
70
|
+
tokenAddress: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
|
|
71
|
+
}, o = {
|
|
72
|
+
name: "STRK Starknet Localnet",
|
|
73
|
+
decimals: 18,
|
|
74
|
+
symbol: "STRK",
|
|
75
|
+
atomicSwapAddress: "0x15cf8b127aa850c97ed10de6f8b300cabc4f09232a57e63667af02fdef8a55a",
|
|
76
|
+
tokenAddress: "0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"
|
|
77
|
+
}, d = {
|
|
78
|
+
name: "ETH Starknet Localnet",
|
|
79
|
+
decimals: 18,
|
|
80
|
+
symbol: "ETH",
|
|
81
|
+
atomicSwapAddress: "0x1890470168440bbb9df50988748924a74ea22de10d22a081e458737b9574e75",
|
|
82
|
+
tokenAddress: "0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"
|
|
83
|
+
};
|
|
24
84
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
85
|
+
t as ArbitrumLocalnet,
|
|
86
|
+
d as ETHStarknetLocalnetAsset,
|
|
87
|
+
a as EthereumLocalnet,
|
|
88
|
+
s as SOLSolanaLocalnetAsset,
|
|
89
|
+
o as STRKStarknetLocalnetAsset,
|
|
90
|
+
e as StarknetLocalnet,
|
|
91
|
+
n as WBTCArbitrumLocalnetAsset,
|
|
92
|
+
r as WBTCEthereumLocalnetAsset,
|
|
93
|
+
c as bitcoinRegtestAsset
|
|
34
94
|
};
|
package/dist/index6.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(n){const e={};for(const t of Object.keys(n)){const i=n[t],{network:a,type:b,...o}=i,s={};for(const c of Object.keys(o)){const r=o[c];s[c]={...r,chain:t}}e[t]=s}return e}exports.buildAssetsWithChain=u;
|
package/dist/index6.js
CHANGED
|
@@ -1,61 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
static fromString(t) {
|
|
16
|
-
const [r, o] = t.split(":");
|
|
17
|
-
if (!(r in i))
|
|
18
|
-
throw new Error(`Invalid chain in asset string: ${r}`);
|
|
19
|
-
return new e(r, o);
|
|
20
|
-
}
|
|
21
|
-
static fromAsset(t) {
|
|
22
|
-
return new e(t.chain, t.symbol);
|
|
23
|
-
}
|
|
24
|
-
/* ---------------- getters (use inherited string content) ---------------- */
|
|
25
|
-
getChain() {
|
|
26
|
-
return this.toString().split(":")[0];
|
|
27
|
-
}
|
|
28
|
-
getSymbol() {
|
|
29
|
-
return this.toString().split(":")[1];
|
|
30
|
-
}
|
|
31
|
-
getNetwork() {
|
|
32
|
-
return n[this.getChain()].network;
|
|
33
|
-
}
|
|
34
|
-
getBlockchainType() {
|
|
35
|
-
return s(this.getChain());
|
|
36
|
-
}
|
|
37
|
-
getAsset() {
|
|
38
|
-
return g[this.getNetwork()][this.getChain()][this.getSymbol()];
|
|
39
|
-
}
|
|
40
|
-
/* ---------------- ensure primitive-like behavior ---------------- */
|
|
41
|
-
// Return primitive string for toString()
|
|
42
|
-
toString() {
|
|
43
|
-
return String.prototype.toString.call(this);
|
|
44
|
-
}
|
|
45
|
-
valueOf() {
|
|
46
|
-
return String.prototype.valueOf.call(this);
|
|
47
|
-
}
|
|
48
|
-
toJSON() {
|
|
49
|
-
return this.toString();
|
|
50
|
-
}
|
|
51
|
-
// ensure template literals / String(...) / + coercion behave like string
|
|
52
|
-
[Symbol.toPrimitive](t) {
|
|
53
|
-
return t === "number" ? NaN : this.toString();
|
|
54
|
-
}
|
|
55
|
-
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
56
|
-
return this.toString();
|
|
57
|
-
}
|
|
1
|
+
function h(n) {
|
|
2
|
+
const o = {};
|
|
3
|
+
for (const t of Object.keys(n)) {
|
|
4
|
+
const i = n[t], { network: r, type: a, ...e } = i, s = {};
|
|
5
|
+
for (const c of Object.keys(e)) {
|
|
6
|
+
const k = e[c];
|
|
7
|
+
s[c] = {
|
|
8
|
+
...k,
|
|
9
|
+
chain: t
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
o[t] = s;
|
|
13
|
+
}
|
|
14
|
+
return o;
|
|
58
15
|
}
|
|
59
16
|
export {
|
|
60
|
-
|
|
17
|
+
h as buildAssetsWithChain
|
|
61
18
|
};
|
package/dist/index7.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@gardenfi/utils"),i=require("./index3.cjs"),p=(t,r,d)=>{const a=t.endpoint(r);return d&&Object.entries(d).forEach(([l,n])=>{n!==void 0&&(Array.isArray(n)?a.searchParams.append(l,n.join(",")):a.searchParams.append(l,n.toString()))}),a},c=t=>e.hasKeys(t,["typed_data","initiate_transaction"])&&typeof t.initiate_transaction=="object"&&t.initiate_transaction&&e.hasKeys(t.initiate_transaction,["to","value","data","gas_limit","chain_id"]),o=t=>e.hasKeys(t,["typed_data","initiate_transaction"])&&typeof t.initiate_transaction=="object"&&t.initiate_transaction&&e.hasKeys(t.initiate_transaction,["to","selector","calldata"]),s=t=>e.hasKeys(t,["to","amount"])&&typeof t.to=="string"&&typeof t.amount=="number",y=t=>e.hasKeys(t,["versioned_tx"])&&typeof t.versioned_tx=="string",u=t=>e.hasKeys(t,["ptb_bytes"])&&Array.isArray(t.ptb_bytes)&&t.ptb_bytes.every(r=>typeof r=="number"),f=t=>e.hasKeys(t,["source_swap","destination_swap"])&&typeof t.source_swap=="object"&&typeof t.destination_swap=="object";function h(t){return c(t)?{type:i.BlockchainType.evm,...t}:o(t)?{type:i.BlockchainType.starknet,...t}:s(t)?{type:i.BlockchainType.bitcoin,...t}:y(t)?{type:i.BlockchainType.solana,...t}:u(t)?{type:i.BlockchainType.sui,...t}:null}function _(t){return c(t)?i.BlockchainType.evm:o(t)?i.BlockchainType.starknet:s(t)?i.BlockchainType.bitcoin:y(t)?i.BlockchainType.solana:u(t)?i.BlockchainType.sui:null}exports.ConstructUrl=p;exports.discriminateOrderResponse=h;exports.getOrderResponseType=_;exports.isBitcoinOrderResponse=s;exports.isEvmOrderResponse=c;exports.isOrder=f;exports.isSolanaOrderResponse=y;exports.isStarknetOrderResponse=o;exports.isSuiOrderResponse=u;
|
package/dist/index7.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { hasKeys as r } from "@gardenfi/utils";
|
|
2
|
+
import { BlockchainType as i } from "./index3.js";
|
|
3
|
+
const m = (t, a, o) => {
|
|
4
|
+
const e = t.endpoint(a);
|
|
5
|
+
return o && Object.entries(o).forEach(([c, n]) => {
|
|
6
|
+
n !== void 0 && (Array.isArray(n) ? e.searchParams.append(c, n.join(",")) : e.searchParams.append(c, n.toString()));
|
|
7
|
+
}), e;
|
|
8
|
+
}, u = (t) => r(t, ["typed_data", "initiate_transaction"]) && typeof t.initiate_transaction == "object" && t.initiate_transaction && r(t.initiate_transaction, [
|
|
9
|
+
"to",
|
|
10
|
+
"value",
|
|
11
|
+
"data",
|
|
12
|
+
"gas_limit",
|
|
13
|
+
"chain_id"
|
|
14
|
+
]), f = (t) => r(t, ["typed_data", "initiate_transaction"]) && typeof t.initiate_transaction == "object" && t.initiate_transaction && r(t.initiate_transaction, ["to", "selector", "calldata"]), y = (t) => r(t, ["to", "amount"]) && typeof t.to == "string" && typeof t.amount == "number", d = (t) => r(t, ["versioned_tx"]) && typeof t.versioned_tx == "string", _ = (t) => r(t, ["ptb_bytes"]) && Array.isArray(t.ptb_bytes) && t.ptb_bytes.every((a) => typeof a == "number"), l = (t) => r(t, ["source_swap", "destination_swap"]) && typeof t.source_swap == "object" && typeof t.destination_swap == "object";
|
|
15
|
+
function p(t) {
|
|
16
|
+
return u(t) ? {
|
|
17
|
+
type: i.evm,
|
|
18
|
+
...t
|
|
19
|
+
} : f(t) ? {
|
|
20
|
+
type: i.starknet,
|
|
21
|
+
...t
|
|
22
|
+
} : y(t) ? {
|
|
23
|
+
type: i.bitcoin,
|
|
24
|
+
...t
|
|
25
|
+
} : d(t) ? {
|
|
26
|
+
type: i.solana,
|
|
27
|
+
...t
|
|
28
|
+
} : _(t) ? {
|
|
29
|
+
type: i.sui,
|
|
30
|
+
...t
|
|
31
|
+
} : null;
|
|
32
|
+
}
|
|
33
|
+
function O(t) {
|
|
34
|
+
return u(t) ? i.evm : f(t) ? i.starknet : y(t) ? i.bitcoin : d(t) ? i.solana : _(t) ? i.sui : null;
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
m as ConstructUrl,
|
|
38
|
+
p as discriminateOrderResponse,
|
|
39
|
+
O as getOrderResponseType,
|
|
40
|
+
y as isBitcoinOrderResponse,
|
|
41
|
+
u as isEvmOrderResponse,
|
|
42
|
+
l as isOrder,
|
|
43
|
+
d as isSolanaOrderResponse,
|
|
44
|
+
f as isStarknetOrderResponse,
|
|
45
|
+
_ as isSuiOrderResponse
|
|
46
|
+
};
|
package/dist/index8.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index4.cjs");class o{constructor(t,r){this.chain=t,this.symbol=r,this.blockchainType=e.getBlockchainType(t),this.formatted=`${t.toLowerCase()}:${r.toLowerCase()}`,this.network=e.Config[t].network,this.asset=e.Assets[t][r]}static from(t){return t instanceof o?t:typeof t=="string"?o.fromString(t):o.fromAsset(t)}static fromChainAndSymbol(t,r){return new o(t,r)}static fromString(t){const[r,n]=t.split(":");if(!(r in e.Chains))throw new Error(`Invalid chain in asset string: ${r}`);return new o(r,n)}static fromAsset(t){return new o(t.chain,t.symbol)}toString(){return this.formatted}}exports.ChainAsset=o;
|
package/dist/index8.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getBlockchainType as i, Config as e, Assets as f, Chains as s } from "./index4.js";
|
|
2
|
+
class o {
|
|
3
|
+
constructor(t, r) {
|
|
4
|
+
this.chain = t, this.symbol = r, this.blockchainType = i(t), this.formatted = `${t.toLowerCase()}:${r.toLowerCase()}`, this.network = e[t].network, this.asset = f[t][r];
|
|
5
|
+
}
|
|
6
|
+
/* ---------------- factories ---------------- */
|
|
7
|
+
static from(t) {
|
|
8
|
+
return t instanceof o ? t : typeof t == "string" ? o.fromString(t) : o.fromAsset(t);
|
|
9
|
+
}
|
|
10
|
+
static fromChainAndSymbol(t, r) {
|
|
11
|
+
return new o(t, r);
|
|
12
|
+
}
|
|
13
|
+
static fromString(t) {
|
|
14
|
+
const [r, n] = t.split(":");
|
|
15
|
+
if (!(r in s))
|
|
16
|
+
throw new Error(`Invalid chain in asset string: ${r}`);
|
|
17
|
+
return new o(r, n);
|
|
18
|
+
}
|
|
19
|
+
static fromAsset(t) {
|
|
20
|
+
return new o(t.chain, t.symbol);
|
|
21
|
+
}
|
|
22
|
+
toString() {
|
|
23
|
+
return this.formatted;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
o as ChainAsset
|
|
28
|
+
};
|
package/dist/index9.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index4.cjs"),u=t=>{const{created_at:n,source_swap:r,destination_swap:d}=t;if(d.redeem_tx_hash)return Number(d.redeem_block_number)||e.isBitcoin(d.chain)?e.OrderStatus.Redeemed:e.OrderStatus.RedeemDetected;if(e.isBitcoin(d.chain)&&r.redeem_tx_hash&&!d.redeem_tx_hash)return e.OrderStatus.Redeemed;if(r.refund_tx_hash)return Number(r.refund_block_number)?e.OrderStatus.Refunded:e.OrderStatus.RefundDetected;if(d.refund_tx_hash)return e.OrderStatus.AwaitingRefund;const a=e.isBitcoin(r.chain)?s(new Date(n),6):s(new Date(n),1);return d.initiate_tx_hash?e.OrderStatus.AwaitingRedeem:r.initiate_tx_hash?a?e.OrderStatus.AwaitingRefund:Number(r.initiate_block_number)?e.OrderStatus.Initiated:e.OrderStatus.InitiateDetected:a?e.OrderStatus.Expired:e.OrderStatus.Created},s=(t,n=1)=>{const r=new Date,d=new Date(t);return d.setHours(d.getHours()+n),r>d},_=t=>{const n=u(t);return n===e.OrderStatus.Redeemed||n===e.OrderStatus.Refunded||n===e.OrderStatus.Expired};var i=(t=>(t.Initiate="Initiate",t.PostRefundSACP="PostRefundSACP",t.Redeem="Redeem",t.Refund="Refund",t.Idle="Idle",t))(i||{});const o=t=>{const{source_swap:n,destination_swap:r}=t;return r.redeem_tx_hash&&Number(r.redeem_block_number)||n.refund_tx_hash&&Number(n.refund_block_number)?"Idle":!r.refund_tx_hash&&r.initiate_tx_hash?"Redeem":"Idle"};exports.OrderAction=i;exports.ParseOrderStatus=u;exports.isCompleted=_;exports.isDeadlinePassed=s;exports.parseAction=o;
|
package/dist/index9.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { OrderStatus as e, isBitcoin as d } from "./index4.js";
|
|
2
|
+
const s = (t) => {
|
|
3
|
+
const { created_at: r, source_swap: n, destination_swap: i } = t;
|
|
4
|
+
if (i.redeem_tx_hash)
|
|
5
|
+
return Number(i.redeem_block_number) ? e.Redeemed : d(i.chain) ? e.Redeemed : e.RedeemDetected;
|
|
6
|
+
if (d(i.chain) && n.redeem_tx_hash && !i.redeem_tx_hash)
|
|
7
|
+
return e.Redeemed;
|
|
8
|
+
if (n.refund_tx_hash)
|
|
9
|
+
return Number(n.refund_block_number) ? e.Refunded : e.RefundDetected;
|
|
10
|
+
if (i.refund_tx_hash) return e.AwaitingRefund;
|
|
11
|
+
const u = d(n.chain) ? a(new Date(r), 6) : a(new Date(r), 1);
|
|
12
|
+
return i.initiate_tx_hash ? e.AwaitingRedeem : n.initiate_tx_hash ? u ? e.AwaitingRefund : Number(n.initiate_block_number) ? e.Initiated : e.InitiateDetected : u ? e.Expired : e.Created;
|
|
13
|
+
}, a = (t, r = 1) => {
|
|
14
|
+
const n = /* @__PURE__ */ new Date(), i = new Date(t);
|
|
15
|
+
return i.setHours(i.getHours() + r), n > i;
|
|
16
|
+
}, m = (t) => {
|
|
17
|
+
const r = s(t);
|
|
18
|
+
return r === e.Redeemed || r === e.Refunded || r === e.Expired;
|
|
19
|
+
};
|
|
20
|
+
var _ = /* @__PURE__ */ ((t) => (t.Initiate = "Initiate", t.PostRefundSACP = "PostRefundSACP", t.Redeem = "Redeem", t.Refund = "Refund", t.Idle = "Idle", t))(_ || {});
|
|
21
|
+
const o = (t) => {
|
|
22
|
+
const { source_swap: r, destination_swap: n } = t;
|
|
23
|
+
return n.redeem_tx_hash && Number(n.redeem_block_number) || r.refund_tx_hash && Number(r.refund_block_number) ? "Idle" : !n.refund_tx_hash && n.initiate_tx_hash ? "Redeem" : "Idle";
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
_ as OrderAction,
|
|
27
|
+
s as ParseOrderStatus,
|
|
28
|
+
m as isCompleted,
|
|
29
|
+
a as isDeadlinePassed,
|
|
30
|
+
o as parseAction
|
|
31
|
+
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { Orderbook } from './lib/orderbook/orderbook';
|
|
2
2
|
export type * from './lib/orderbook/orderbook.types';
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export * from './lib/asset';
|
|
3
|
+
export { BlockchainType } from './lib/constants/asset.types';
|
|
4
|
+
export type { Asset, AssetCommon, AssetToken, BitcoinChains, Chain, ChainsByBlockchainType, ChainsByNetwork, EVMChains, LocalnetOnlyChains, MainnetOnlyChains, SolanaChains, SuiChains, StarknetChains, TestnetOnlyChains, } from './lib/constants/asset.types';
|
|
5
|
+
export * from './lib/constants/asset';
|
|
6
|
+
export * from './lib/constants/localnetConstants';
|
|
7
|
+
export * from './lib/constants/utils';
|
|
6
8
|
export { isSuiOrderResponse, ConstructUrl, discriminateOrderResponse, getOrderResponseType, isBitcoinOrderResponse, isEvmOrderResponse, isOrder, isSolanaOrderResponse, isStarknetOrderResponse, } from './lib/utils';
|
|
7
9
|
export { ChainAsset } from './lib/chainAsset/chainAsset';
|
|
8
|
-
export type { ChainAssetString } from './lib/chainAsset/chainAsset';
|
|
10
|
+
export type { ChainAssetString, AssetLike } from './lib/chainAsset/chainAsset';
|
|
11
|
+
export { OrderAction, ParseOrderStatus, isCompleted, isDeadlinePassed, parseAction, } from './lib/orderStatus/orderStatus';
|
package/dist/src/lib/asset.d.ts
CHANGED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { Network } from '@gardenfi/utils';
|
|
2
|
-
import { CreateOrderRequest } from './orderbook/orderbook.types';
|
|
3
|
-
import { ChainAsset } from './chainAsset/chainAsset';
|
|
4
|
-
|
|
5
|
-
export type AssetCommon = {
|
|
6
|
-
name: string;
|
|
7
|
-
decimals: number;
|
|
8
|
-
symbol: string;
|
|
9
|
-
chain: Chain;
|
|
10
|
-
logo?: string;
|
|
11
|
-
atomicSwapAddress: string;
|
|
12
|
-
};
|
|
13
|
-
export declare enum OrderLifecycle {
|
|
14
|
-
refunded = "refunded",
|
|
15
|
-
expired = "expired",
|
|
16
|
-
completed = "completed",
|
|
17
|
-
inProgress = "in-progress",
|
|
18
|
-
notInitiated = "not-initiated",
|
|
19
|
-
all = "all",
|
|
20
|
-
pending = "pending",
|
|
21
|
-
fulfilled = "fulfilled"
|
|
22
|
-
}
|
|
23
|
-
export type AssetToken = AssetCommon & {
|
|
24
|
-
tokenAddress: string;
|
|
25
|
-
};
|
|
26
|
-
export type Asset = AssetToken;
|
|
27
|
-
export declare enum BlockchainType {
|
|
28
|
-
bitcoin = "bitcoin",
|
|
29
|
-
evm = "evm",
|
|
30
|
-
solana = "solana",
|
|
31
|
-
starknet = "starknet",
|
|
32
|
-
sui = "sui"
|
|
33
|
-
}
|
|
34
|
-
export declare enum NetworkType {
|
|
35
|
-
mainnet = "mainnet",
|
|
36
|
-
testnet = "testnet",
|
|
37
|
-
localnet = "localnet"
|
|
38
|
-
}
|
|
39
|
-
export declare const ChainsConfig: {
|
|
40
|
-
readonly bitcoin: {
|
|
41
|
-
readonly type: BlockchainType.bitcoin;
|
|
42
|
-
readonly network: Network.MAINNET;
|
|
43
|
-
};
|
|
44
|
-
readonly bitcoin_testnet: {
|
|
45
|
-
readonly type: BlockchainType.bitcoin;
|
|
46
|
-
readonly network: Network.TESTNET;
|
|
47
|
-
};
|
|
48
|
-
readonly bitcoin_regtest: {
|
|
49
|
-
readonly type: BlockchainType.bitcoin;
|
|
50
|
-
readonly network: Network.LOCALNET;
|
|
51
|
-
};
|
|
52
|
-
readonly ethereum: {
|
|
53
|
-
readonly type: BlockchainType.evm;
|
|
54
|
-
readonly network: Network.MAINNET;
|
|
55
|
-
};
|
|
56
|
-
readonly base: {
|
|
57
|
-
readonly type: BlockchainType.evm;
|
|
58
|
-
readonly network: Network.MAINNET;
|
|
59
|
-
};
|
|
60
|
-
readonly arbitrum: {
|
|
61
|
-
readonly type: BlockchainType.evm;
|
|
62
|
-
readonly network: Network.MAINNET;
|
|
63
|
-
};
|
|
64
|
-
readonly ethereum_sepolia: {
|
|
65
|
-
readonly type: BlockchainType.evm;
|
|
66
|
-
readonly network: Network.TESTNET;
|
|
67
|
-
};
|
|
68
|
-
readonly arbitrum_localnet: {
|
|
69
|
-
readonly type: BlockchainType.evm;
|
|
70
|
-
readonly network: Network.LOCALNET;
|
|
71
|
-
};
|
|
72
|
-
readonly arbitrum_sepolia: {
|
|
73
|
-
readonly type: BlockchainType.evm;
|
|
74
|
-
readonly network: Network.TESTNET;
|
|
75
|
-
};
|
|
76
|
-
readonly ethereum_localnet: {
|
|
77
|
-
readonly type: BlockchainType.evm;
|
|
78
|
-
readonly network: Network.LOCALNET;
|
|
79
|
-
};
|
|
80
|
-
readonly base_sepolia: {
|
|
81
|
-
readonly type: BlockchainType.evm;
|
|
82
|
-
readonly network: Network.TESTNET;
|
|
83
|
-
};
|
|
84
|
-
readonly solana: {
|
|
85
|
-
readonly type: BlockchainType.solana;
|
|
86
|
-
readonly network: Network.MAINNET;
|
|
87
|
-
};
|
|
88
|
-
readonly solana_testnet: {
|
|
89
|
-
readonly type: BlockchainType.solana;
|
|
90
|
-
readonly network: Network.TESTNET;
|
|
91
|
-
};
|
|
92
|
-
readonly solana_localnet: {
|
|
93
|
-
readonly type: BlockchainType.solana;
|
|
94
|
-
readonly network: Network.LOCALNET;
|
|
95
|
-
};
|
|
96
|
-
readonly bera_testnet: {
|
|
97
|
-
readonly type: BlockchainType.evm;
|
|
98
|
-
readonly network: Network.TESTNET;
|
|
99
|
-
};
|
|
100
|
-
readonly citrea_testnet: {
|
|
101
|
-
readonly type: BlockchainType.evm;
|
|
102
|
-
readonly network: Network.TESTNET;
|
|
103
|
-
};
|
|
104
|
-
readonly bera: {
|
|
105
|
-
readonly type: BlockchainType.evm;
|
|
106
|
-
readonly network: Network.MAINNET;
|
|
107
|
-
};
|
|
108
|
-
readonly monad_testnet: {
|
|
109
|
-
readonly type: BlockchainType.evm;
|
|
110
|
-
readonly network: Network.TESTNET;
|
|
111
|
-
};
|
|
112
|
-
readonly starknet: {
|
|
113
|
-
readonly type: BlockchainType.starknet;
|
|
114
|
-
readonly network: Network.MAINNET;
|
|
115
|
-
};
|
|
116
|
-
readonly starknet_sepolia: {
|
|
117
|
-
readonly type: BlockchainType.starknet;
|
|
118
|
-
readonly network: Network.TESTNET;
|
|
119
|
-
};
|
|
120
|
-
readonly starknet_devnet: {
|
|
121
|
-
readonly type: BlockchainType.starknet;
|
|
122
|
-
readonly network: Network.LOCALNET;
|
|
123
|
-
};
|
|
124
|
-
readonly hyperliquid_testnet: {
|
|
125
|
-
readonly type: BlockchainType.evm;
|
|
126
|
-
readonly network: Network.TESTNET;
|
|
127
|
-
};
|
|
128
|
-
readonly hyperliquid: {
|
|
129
|
-
readonly type: BlockchainType.evm;
|
|
130
|
-
readonly network: Network.MAINNET;
|
|
131
|
-
};
|
|
132
|
-
readonly unichain: {
|
|
133
|
-
readonly type: BlockchainType.evm;
|
|
134
|
-
readonly network: Network.MAINNET;
|
|
135
|
-
};
|
|
136
|
-
readonly corn: {
|
|
137
|
-
readonly type: BlockchainType.evm;
|
|
138
|
-
readonly network: Network.MAINNET;
|
|
139
|
-
};
|
|
140
|
-
readonly botanix: {
|
|
141
|
-
readonly type: BlockchainType.evm;
|
|
142
|
-
readonly network: Network.MAINNET;
|
|
143
|
-
};
|
|
144
|
-
readonly bnbchain: {
|
|
145
|
-
readonly type: BlockchainType.evm;
|
|
146
|
-
readonly network: Network.MAINNET;
|
|
147
|
-
};
|
|
148
|
-
readonly bnbchain_testnet: {
|
|
149
|
-
readonly type: BlockchainType.evm;
|
|
150
|
-
readonly network: Network.TESTNET;
|
|
151
|
-
};
|
|
152
|
-
readonly sui: {
|
|
153
|
-
readonly type: BlockchainType.sui;
|
|
154
|
-
readonly network: Network.MAINNET;
|
|
155
|
-
};
|
|
156
|
-
readonly sui_testnet: {
|
|
157
|
-
readonly type: BlockchainType.sui;
|
|
158
|
-
readonly network: Network.TESTNET;
|
|
159
|
-
};
|
|
160
|
-
readonly core: {
|
|
161
|
-
readonly type: BlockchainType.evm;
|
|
162
|
-
readonly network: Network.MAINNET;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
export declare const Chains: Record<"bitcoin" | "bitcoin_testnet" | "bitcoin_regtest" | "ethereum" | "base" | "arbitrum" | "ethereum_sepolia" | "arbitrum_localnet" | "arbitrum_sepolia" | "ethereum_localnet" | "base_sepolia" | "solana" | "solana_testnet" | "solana_localnet" | "bera_testnet" | "citrea_testnet" | "bera" | "monad_testnet" | "starknet" | "starknet_sepolia" | "starknet_devnet" | "hyperliquid_testnet" | "hyperliquid" | "unichain" | "corn" | "botanix" | "bnbchain" | "bnbchain_testnet" | "sui" | "sui_testnet" | "core", "bitcoin" | "bitcoin_testnet" | "bitcoin_regtest" | "ethereum" | "base" | "arbitrum" | "ethereum_sepolia" | "arbitrum_localnet" | "arbitrum_sepolia" | "ethereum_localnet" | "base_sepolia" | "solana" | "solana_testnet" | "solana_localnet" | "bera_testnet" | "citrea_testnet" | "bera" | "monad_testnet" | "starknet" | "starknet_sepolia" | "starknet_devnet" | "hyperliquid_testnet" | "hyperliquid" | "unichain" | "corn" | "botanix" | "bnbchain" | "bnbchain_testnet" | "sui" | "sui_testnet" | "core">;
|
|
166
|
-
export type Chain = keyof typeof ChainsConfig;
|
|
167
|
-
export type EvmChain = {
|
|
168
|
-
[K in Chain]: (typeof ChainsConfig)[K] extends {
|
|
169
|
-
type: BlockchainType.evm;
|
|
170
|
-
} ? K : never;
|
|
171
|
-
}[Chain];
|
|
172
|
-
export type ChainsByNetwork<T> = {
|
|
173
|
-
[K in Chain]: (typeof ChainsConfig)[K] extends {
|
|
174
|
-
network: T;
|
|
175
|
-
} ? K : never;
|
|
176
|
-
}[Chain];
|
|
177
|
-
export type Assets = {
|
|
178
|
-
[network in Network]: {
|
|
179
|
-
[chain in ChainsByNetwork<network>]: {
|
|
180
|
-
[symbol: string]: Asset;
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
export declare const isMainnet: (chain: Chain) => boolean;
|
|
185
|
-
export declare const isBitcoin: (chain: Chain) => boolean;
|
|
186
|
-
export declare const isEVM: (chain: Chain) => boolean;
|
|
187
|
-
export declare const isSolana: (chain: Chain) => boolean;
|
|
188
|
-
export declare const isStarknet: (chain: Chain) => boolean;
|
|
189
|
-
export declare const isSui: (chain: Chain) => boolean;
|
|
190
|
-
export declare const getBlockchainType: (chain: Chain) => BlockchainType;
|
|
191
|
-
export declare const NativeTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
192
|
-
export declare const NATIVE_TOKENS: {
|
|
193
|
-
evm: string;
|
|
194
|
-
solana: string;
|
|
195
|
-
sui: string;
|
|
196
|
-
};
|
|
197
|
-
export declare const isEvmNativeToken: (chain: Chain, tokenAddress: string) => boolean;
|
|
198
|
-
export declare const isSolanaNativeToken: (chain: Chain, tokenAddress: string) => boolean;
|
|
199
|
-
export declare const isSuiNativeToken: (chain: Chain, tokenAddress: string) => boolean;
|
|
200
|
-
export declare const isNativeToken: (asset: ChainAsset) => boolean;
|
|
201
|
-
export declare const getChainsFromOrder: (order: CreateOrderRequest) => {
|
|
202
|
-
sourceChain: Chain;
|
|
203
|
-
destinationChain: Chain;
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* Determines the blockchain type from a formatted asset string.
|
|
207
|
-
* @param assetChain - The formatted asset string (e.g., "bitcoin:btc", "ethereum:eth")
|
|
208
|
-
* @returns The chain type as a string: "bitcoin", "evm", "solana", or "starknet"
|
|
209
|
-
*/
|
|
210
|
-
export declare const getChainTypeFromAssetChain: (assetChain: string) => BlockchainType;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { Network } from '@gardenfi/utils';
|
|
2
|
-
import { Asset, BlockchainType, Chain } from '../asset';
|
|
2
|
+
import { Asset, BlockchainType, Chain } from '../constants/asset.types';
|
|
3
3
|
|
|
4
4
|
export type ChainAssetString = `${Chain}:${string}`;
|
|
5
|
-
export
|
|
5
|
+
export type AssetLike = Asset | ChainAssetString | ChainAsset | string;
|
|
6
|
+
export declare class ChainAsset {
|
|
7
|
+
chain: Chain;
|
|
8
|
+
symbol: string;
|
|
9
|
+
blockchainType: BlockchainType;
|
|
10
|
+
formatted: ChainAssetString;
|
|
11
|
+
network: Network;
|
|
12
|
+
asset: Asset;
|
|
6
13
|
constructor(chain: Chain, symbol: string);
|
|
7
|
-
static from(asset:
|
|
14
|
+
static from(asset: AssetLike): ChainAsset;
|
|
8
15
|
static fromChainAndSymbol(chain: Chain, symbol: string): ChainAsset;
|
|
9
16
|
static fromString(formatted: ChainAssetString | string): ChainAsset;
|
|
10
17
|
static fromAsset(asset: Asset): ChainAsset;
|
|
11
|
-
getChain(): Chain;
|
|
12
|
-
getSymbol(): string;
|
|
13
|
-
getNetwork(): Network;
|
|
14
|
-
getBlockchainType(): BlockchainType;
|
|
15
|
-
getAsset(): Asset;
|
|
16
18
|
toString(): string;
|
|
17
|
-
valueOf(): string;
|
|
18
|
-
toJSON(): string;
|
|
19
|
-
[Symbol.toPrimitive](_hint: 'string' | 'number' | 'default'): string | number;
|
|
20
19
|
}
|