@perspectivefi/addresses 0.0.0-stage → 0.1.0
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/README.md +212 -2
- package/dist/cli.js +280 -0
- package/dist/core-DQQq-Yh9.d.mts +29 -0
- package/dist/core-DQQq-Yh9.d.ts +29 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +59 -0
- package/dist/index.mjs +50 -0
- package/dist/prod.d.mts +13 -0
- package/dist/prod.d.ts +13 -0
- package/dist/prod.js +59 -0
- package/dist/prod.mjs +50 -0
- package/dist/registry.json +21420 -0
- package/eslint/index.cjs +55 -0
- package/eslint/index.d.ts +21 -0
- package/package.json +82 -5
package/dist/prod.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { C as ChainInput, A as AddressKey, a as ChainRef, E as Entry, S as Status } from './core-DQQq-Yh9.mjs';
|
|
2
|
+
export { K as Kind, b as Source } from './core-DQQq-Yh9.mjs';
|
|
3
|
+
|
|
4
|
+
declare const address: (chain: ChainInput, key: AddressKey) => string | undefined;
|
|
5
|
+
declare const requireAddress: (chain: ChainInput, key: AddressKey) => string;
|
|
6
|
+
declare const entry: (chain: ChainInput, key: AddressKey) => Entry | undefined;
|
|
7
|
+
declare const findByAddress: (chain: ChainInput, address: string) => Entry | undefined;
|
|
8
|
+
declare const statusOf: (chain: ChainInput, address: string) => Status | undefined;
|
|
9
|
+
declare const isProdSafe: (chain: ChainInput, address: string) => boolean;
|
|
10
|
+
declare const entries: (chain?: ChainInput) => Entry[];
|
|
11
|
+
declare const chains: () => ChainRef[];
|
|
12
|
+
|
|
13
|
+
export { AddressKey, ChainRef, Entry, Status, address, chains, entries, entry, findByAddress, isProdSafe, requireAddress, statusOf };
|
package/dist/prod.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { C as ChainInput, A as AddressKey, a as ChainRef, E as Entry, S as Status } from './core-DQQq-Yh9.js';
|
|
2
|
+
export { K as Kind, b as Source } from './core-DQQq-Yh9.js';
|
|
3
|
+
|
|
4
|
+
declare const address: (chain: ChainInput, key: AddressKey) => string | undefined;
|
|
5
|
+
declare const requireAddress: (chain: ChainInput, key: AddressKey) => string;
|
|
6
|
+
declare const entry: (chain: ChainInput, key: AddressKey) => Entry | undefined;
|
|
7
|
+
declare const findByAddress: (chain: ChainInput, address: string) => Entry | undefined;
|
|
8
|
+
declare const statusOf: (chain: ChainInput, address: string) => Status | undefined;
|
|
9
|
+
declare const isProdSafe: (chain: ChainInput, address: string) => boolean;
|
|
10
|
+
declare const entries: (chain?: ChainInput) => Entry[];
|
|
11
|
+
declare const chains: () => ChainRef[];
|
|
12
|
+
|
|
13
|
+
export { AddressKey, ChainRef, Entry, Status, address, chains, entries, entry, findByAddress, isProdSafe, requireAddress, statusOf };
|
package/dist/prod.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/core.ts
|
|
4
|
+
var normalise = (chain, address2) => chain === "stellar" ? address2 : address2.toLowerCase();
|
|
5
|
+
function createRegistry(data, scope) {
|
|
6
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
7
|
+
const byAddress = /* @__PURE__ */ new Map();
|
|
8
|
+
const chainList = [];
|
|
9
|
+
for (const e of data) {
|
|
10
|
+
byKey.set(`${e.chain}:${e.key}`, e);
|
|
11
|
+
byAddress.set(`${e.chain}:${normalise(e.chain, e.address)}`, e);
|
|
12
|
+
if (!chainList.includes(e.chain)) chainList.push(e.chain);
|
|
13
|
+
}
|
|
14
|
+
const entry2 = (chain, key) => byKey.get(`${chain}:${key}`);
|
|
15
|
+
const findByAddress2 = (chain, address2) => byAddress.get(`${chain}:${normalise(chain, address2)}`);
|
|
16
|
+
return {
|
|
17
|
+
entry: entry2,
|
|
18
|
+
findByAddress: findByAddress2,
|
|
19
|
+
address: (chain, key) => entry2(chain, key)?.address,
|
|
20
|
+
requireAddress(chain, key) {
|
|
21
|
+
const found = entry2(chain, key);
|
|
22
|
+
if (!found) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`@perspectivefi/addresses: no address for key "${key}" on chain ${chain}` + (` (the /prod entry point only contains addresses with status "safe")` )
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return found.address;
|
|
28
|
+
},
|
|
29
|
+
statusOf: (chain, address2) => findByAddress2(chain, address2)?.status,
|
|
30
|
+
isProdSafe: (chain, address2) => findByAddress2(chain, address2)?.status === "safe",
|
|
31
|
+
entries: (chain) => chain === void 0 ? [...data] : data.filter((e) => e.chain === chain),
|
|
32
|
+
chains: () => [...chainList]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/generated/registry.ts
|
|
37
|
+
var SAFE = [];
|
|
38
|
+
|
|
39
|
+
// src/prod.ts
|
|
40
|
+
var registry = createRegistry(SAFE);
|
|
41
|
+
var {
|
|
42
|
+
address,
|
|
43
|
+
requireAddress,
|
|
44
|
+
entry,
|
|
45
|
+
findByAddress,
|
|
46
|
+
statusOf,
|
|
47
|
+
isProdSafe,
|
|
48
|
+
entries,
|
|
49
|
+
chains
|
|
50
|
+
} = registry;
|
|
51
|
+
|
|
52
|
+
exports.address = address;
|
|
53
|
+
exports.chains = chains;
|
|
54
|
+
exports.entries = entries;
|
|
55
|
+
exports.entry = entry;
|
|
56
|
+
exports.findByAddress = findByAddress;
|
|
57
|
+
exports.isProdSafe = isProdSafe;
|
|
58
|
+
exports.requireAddress = requireAddress;
|
|
59
|
+
exports.statusOf = statusOf;
|
package/dist/prod.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/core.ts
|
|
2
|
+
var normalise = (chain, address2) => chain === "stellar" ? address2 : address2.toLowerCase();
|
|
3
|
+
function createRegistry(data, scope) {
|
|
4
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
5
|
+
const byAddress = /* @__PURE__ */ new Map();
|
|
6
|
+
const chainList = [];
|
|
7
|
+
for (const e of data) {
|
|
8
|
+
byKey.set(`${e.chain}:${e.key}`, e);
|
|
9
|
+
byAddress.set(`${e.chain}:${normalise(e.chain, e.address)}`, e);
|
|
10
|
+
if (!chainList.includes(e.chain)) chainList.push(e.chain);
|
|
11
|
+
}
|
|
12
|
+
const entry2 = (chain, key) => byKey.get(`${chain}:${key}`);
|
|
13
|
+
const findByAddress2 = (chain, address2) => byAddress.get(`${chain}:${normalise(chain, address2)}`);
|
|
14
|
+
return {
|
|
15
|
+
entry: entry2,
|
|
16
|
+
findByAddress: findByAddress2,
|
|
17
|
+
address: (chain, key) => entry2(chain, key)?.address,
|
|
18
|
+
requireAddress(chain, key) {
|
|
19
|
+
const found = entry2(chain, key);
|
|
20
|
+
if (!found) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`@perspectivefi/addresses: no address for key "${key}" on chain ${chain}` + (` (the /prod entry point only contains addresses with status "safe")` )
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return found.address;
|
|
26
|
+
},
|
|
27
|
+
statusOf: (chain, address2) => findByAddress2(chain, address2)?.status,
|
|
28
|
+
isProdSafe: (chain, address2) => findByAddress2(chain, address2)?.status === "safe",
|
|
29
|
+
entries: (chain) => chain === void 0 ? [...data] : data.filter((e) => e.chain === chain),
|
|
30
|
+
chains: () => [...chainList]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/generated/registry.ts
|
|
35
|
+
var SAFE = [];
|
|
36
|
+
|
|
37
|
+
// src/prod.ts
|
|
38
|
+
var registry = createRegistry(SAFE);
|
|
39
|
+
var {
|
|
40
|
+
address,
|
|
41
|
+
requireAddress,
|
|
42
|
+
entry,
|
|
43
|
+
findByAddress,
|
|
44
|
+
statusOf,
|
|
45
|
+
isProdSafe,
|
|
46
|
+
entries,
|
|
47
|
+
chains
|
|
48
|
+
} = registry;
|
|
49
|
+
|
|
50
|
+
export { address, chains, entries, entry, findByAddress, isProdSafe, requireAddress, statusOf };
|