@gardenfi/orderbook 3.1.3-beta.18 → 3.1.3-beta.19
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/index8.cjs +1 -1
- package/dist/index8.js +14 -14
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +36 -26
- package/package.json +2 -2
package/dist/index8.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index4.cjs");class o{constructor(t,r){this.chain=t,this.symbol=r,this.blockchainType=i.getBlockchainType(t),this.formatted=`${t.toLowerCase()}:${r.toLowerCase()}`,this.network=i.Config[t].network,this.asset=i.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 i.Chains))throw new Error(`Invalid chain in asset string: ${r}`);return new o(r,n)}static fromAsset(t){return t.id?o.from(t.id):new o(t.chain,t.symbol)}toString(){return this.formatted}toJSON(){return this.formatted}}exports.ChainAsset=o;
|
package/dist/index8.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { getBlockchainType as
|
|
1
|
+
import { getBlockchainType as n, Config as e, Assets as f, Chains as m } from "./index4.js";
|
|
2
2
|
class o {
|
|
3
|
-
constructor(
|
|
4
|
-
this.chain =
|
|
3
|
+
constructor(r, t) {
|
|
4
|
+
this.chain = r, this.symbol = t, this.blockchainType = n(r), this.formatted = `${r.toLowerCase()}:${t.toLowerCase()}`, this.network = e[r].network, this.asset = f[r][t];
|
|
5
5
|
}
|
|
6
6
|
/* ---------------- factories ---------------- */
|
|
7
|
-
static from(
|
|
8
|
-
return
|
|
7
|
+
static from(r) {
|
|
8
|
+
return r instanceof o ? r : typeof r == "string" ? o.fromString(r) : o.fromAsset(r);
|
|
9
9
|
}
|
|
10
|
-
static fromChainAndSymbol(
|
|
11
|
-
return new o(
|
|
10
|
+
static fromChainAndSymbol(r, t) {
|
|
11
|
+
return new o(r, t);
|
|
12
12
|
}
|
|
13
|
-
static fromString(
|
|
14
|
-
const [
|
|
15
|
-
if (!(
|
|
16
|
-
throw new Error(`Invalid chain in asset string: ${
|
|
17
|
-
return new o(
|
|
13
|
+
static fromString(r) {
|
|
14
|
+
const [t, i] = r.split(":");
|
|
15
|
+
if (!(t in m))
|
|
16
|
+
throw new Error(`Invalid chain in asset string: ${t}`);
|
|
17
|
+
return new o(t, i);
|
|
18
18
|
}
|
|
19
|
-
static fromAsset(
|
|
20
|
-
return new o(
|
|
19
|
+
static fromAsset(r) {
|
|
20
|
+
return r.id ? o.from(r.id) : new o(r.chain, r.symbol);
|
|
21
21
|
}
|
|
22
22
|
toString() {
|
|
23
23
|
return this.formatted;
|
package/dist/index9.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@gardenfi/utils"),d=require("./index4.cjs"),i=require("./index3.cjs"),o={[i.BlockchainType.bitcoin]:{address:(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@gardenfi/utils"),d=require("./index4.cjs"),i=require("./index3.cjs"),o={[i.BlockchainType.bitcoin]:{address:(r,t)=>new s.Url("address",r).endpoint(t).toString(),tx:(r,t)=>new s.Url("tx",r).endpoint(t).toString()},[i.BlockchainType.tron]:{address:(r,t)=>`${r}/#/address/${t}`,tx:(r,t)=>`${r}/#/transaction/${t.slice(2)}`},[i.BlockchainType.starknet]:{address:(r,t)=>new s.Url("contract",r).endpoint(t).toString(),tx:(r,t)=>new s.Url("tx",r).endpoint(t).toString()},[i.BlockchainType.xrpl]:{address:(r,t)=>new s.Url("accounts",r).endpoint(t).toString(),tx:(r,t)=>new s.Url("transactions",r).endpoint(t).toString()},[i.BlockchainType.solana]:{address:(r,t,n)=>{let e=new s.Url("address",r).endpoint(t);return n===s.Network.TESTNET&&(e=e.addSearchParams({cluster:"devnet"})),e.toString()},tx:(r,t,n)=>{let e=new s.Url("tx",r).endpoint(t);return n===s.Network.TESTNET&&(e=e.addSearchParams({cluster:"devnet"})),e.toString()}},[i.BlockchainType.spark]:{address:(r,t,n)=>{const e=new s.Url("address",r).endpoint(t);return n===s.Network.TESTNET?e.addSearchParams({network:"regtest"}).toString():e.toString()},tx:(r,t,n)=>{const e=new s.Url("tx",r).endpoint(t);return n===s.Network.TESTNET?e.addSearchParams({network:"regtest"}).toString():e.toString()}},default:{address:(r,t)=>new s.Url("address",r).endpoint(t).toString(),tx:(r,t)=>new s.Url("tx",r).endpoint(t).toString()}};class a{constructor(t,n,e){this.explorerUrl=n,this.network=e,this.chainType=d.getBlockchainType(t)}static from(t,n,e){return new a(t,n,e)}getAddressLink(t){return(o[this.chainType]??o.default).address(this.explorerUrl,t,this.network)}getTxLink(t){const n=this.extractTxHash(t);return(o[this.chainType]??o.default).tx(this.explorerUrl,n,this.network)}extractTxHash(t){var n,e;return((e=(n=t.split(",").at(-1))==null?void 0:n.split(":").at(0))==null?void 0:e.trim())??""}}exports.ExplorerUrlBuilder=a;
|
package/dist/index9.js
CHANGED
|
@@ -1,55 +1,65 @@
|
|
|
1
|
-
import { Url as s, Network as
|
|
1
|
+
import { Url as s, Network as o } from "@gardenfi/utils";
|
|
2
2
|
import { getBlockchainType as c } from "./index4.js";
|
|
3
3
|
import { BlockchainType as i } from "./index3.js";
|
|
4
|
-
const
|
|
4
|
+
const d = {
|
|
5
5
|
[i.bitcoin]: {
|
|
6
|
-
address: (
|
|
7
|
-
tx: (
|
|
6
|
+
address: (r, t) => new s("address", r).endpoint(t).toString(),
|
|
7
|
+
tx: (r, t) => new s("tx", r).endpoint(t).toString()
|
|
8
8
|
},
|
|
9
9
|
[i.tron]: {
|
|
10
|
-
address: (
|
|
11
|
-
tx: (
|
|
10
|
+
address: (r, t) => `${r}/#/address/${t}`,
|
|
11
|
+
tx: (r, t) => `${r}/#/transaction/${t.slice(2)}`
|
|
12
12
|
},
|
|
13
13
|
[i.starknet]: {
|
|
14
|
-
address: (
|
|
15
|
-
tx: (
|
|
14
|
+
address: (r, t) => new s("contract", r).endpoint(t).toString(),
|
|
15
|
+
tx: (r, t) => new s("tx", r).endpoint(t).toString()
|
|
16
16
|
},
|
|
17
17
|
[i.xrpl]: {
|
|
18
|
-
address: (
|
|
19
|
-
tx: (
|
|
18
|
+
address: (r, t) => new s("accounts", r).endpoint(t).toString(),
|
|
19
|
+
tx: (r, t) => new s("transactions", r).endpoint(t).toString()
|
|
20
20
|
},
|
|
21
21
|
[i.solana]: {
|
|
22
|
-
address: (
|
|
23
|
-
let
|
|
24
|
-
return n ===
|
|
22
|
+
address: (r, t, n) => {
|
|
23
|
+
let e = new s("address", r).endpoint(t);
|
|
24
|
+
return n === o.TESTNET && (e = e.addSearchParams({ cluster: "devnet" })), e.toString();
|
|
25
25
|
},
|
|
26
|
-
tx: (
|
|
27
|
-
let
|
|
28
|
-
return n ===
|
|
26
|
+
tx: (r, t, n) => {
|
|
27
|
+
let e = new s("tx", r).endpoint(t);
|
|
28
|
+
return n === o.TESTNET && (e = e.addSearchParams({ cluster: "devnet" })), e.toString();
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
[i.spark]: {
|
|
32
|
+
address: (r, t, n) => {
|
|
33
|
+
const e = new s("address", r).endpoint(t);
|
|
34
|
+
return n === o.TESTNET ? e.addSearchParams({ network: "regtest" }).toString() : e.toString();
|
|
35
|
+
},
|
|
36
|
+
tx: (r, t, n) => {
|
|
37
|
+
const e = new s("tx", r).endpoint(t);
|
|
38
|
+
return n === o.TESTNET ? e.addSearchParams({ network: "regtest" }).toString() : e.toString();
|
|
29
39
|
}
|
|
30
40
|
},
|
|
31
41
|
default: {
|
|
32
|
-
address: (
|
|
33
|
-
tx: (
|
|
42
|
+
address: (r, t) => new s("address", r).endpoint(t).toString(),
|
|
43
|
+
tx: (r, t) => new s("tx", r).endpoint(t).toString()
|
|
34
44
|
}
|
|
35
45
|
};
|
|
36
46
|
class a {
|
|
37
|
-
constructor(t, n,
|
|
38
|
-
this.explorerUrl = n, this.network =
|
|
47
|
+
constructor(t, n, e) {
|
|
48
|
+
this.explorerUrl = n, this.network = e, this.chainType = c(t);
|
|
39
49
|
}
|
|
40
|
-
static from(t, n,
|
|
41
|
-
return new a(t, n,
|
|
50
|
+
static from(t, n, e) {
|
|
51
|
+
return new a(t, n, e);
|
|
42
52
|
}
|
|
43
53
|
getAddressLink(t) {
|
|
44
|
-
return (
|
|
54
|
+
return (d[this.chainType] ?? d.default).address(this.explorerUrl, t, this.network);
|
|
45
55
|
}
|
|
46
56
|
getTxLink(t) {
|
|
47
57
|
const n = this.extractTxHash(t);
|
|
48
|
-
return (
|
|
58
|
+
return (d[this.chainType] ?? d.default).tx(this.explorerUrl, n, this.network);
|
|
49
59
|
}
|
|
50
60
|
extractTxHash(t) {
|
|
51
|
-
var n,
|
|
52
|
-
return ((
|
|
61
|
+
var n, e;
|
|
62
|
+
return ((e = (n = t.split(",").at(-1)) == null ? void 0 : n.split(":").at(0)) == null ? void 0 : e.trim()) ?? "";
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
65
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/orderbook",
|
|
3
|
-
"version": "3.1.3-beta.
|
|
3
|
+
"version": "3.1.3-beta.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@coral-xyz/anchor": "^0.31.1",
|
|
31
|
-
"@gardenfi/utils": "3.1.1-beta.
|
|
31
|
+
"@gardenfi/utils": "3.1.1-beta.17",
|
|
32
32
|
"bufferutil": "^4.0.8",
|
|
33
33
|
"node-cache": "^5.1.2",
|
|
34
34
|
"siwe": "^2.1.4",
|