@bigmi/core 0.4.5 → 0.5.1
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/CHANGELOG.md +16 -0
- package/README.md +1 -3
- package/dist/cjs/chains/bitcoin.d.ts +2 -1
- package/dist/cjs/chains/bitcoin.js +2 -1
- package/dist/cjs/chains/bitcoin.js.map +1 -1
- package/dist/cjs/chains/signet.d.ts +24 -0
- package/dist/cjs/chains/signet.js +25 -0
- package/dist/cjs/chains/signet.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -4
- package/dist/cjs/index.js +6 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/address.d.ts +1 -5
- package/dist/cjs/types/address.js +1 -7
- package/dist/cjs/types/address.js.map +1 -1
- package/dist/cjs/types/chain.d.ts +16 -1
- package/dist/cjs/types/chain.js +18 -0
- package/dist/cjs/types/chain.js.map +1 -1
- package/dist/cjs/utils/getAddressInfo.d.ts +2 -0
- package/dist/cjs/utils/getAddressInfo.js +23 -8
- package/dist/cjs/utils/getAddressInfo.js.map +1 -1
- package/dist/cjs/utils/isAddress.d.ts +1 -1
- package/dist/cjs/utils/isAddress.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/chains/bitcoin.d.ts +2 -1
- package/dist/esm/chains/bitcoin.js +2 -1
- package/dist/esm/chains/bitcoin.js.map +1 -1
- package/dist/esm/chains/signet.d.ts +24 -0
- package/dist/esm/chains/signet.js +22 -0
- package/dist/esm/chains/signet.js.map +1 -0
- package/dist/esm/index.d.ts +3 -4
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/address.d.ts +1 -5
- package/dist/esm/types/address.js +0 -6
- package/dist/esm/types/address.js.map +1 -1
- package/dist/esm/types/chain.d.ts +16 -1
- package/dist/esm/types/chain.js +17 -1
- package/dist/esm/types/chain.js.map +1 -1
- package/dist/esm/utils/getAddressInfo.d.ts +2 -0
- package/dist/esm/utils/getAddressInfo.js +15 -1
- package/dist/esm/utils/getAddressInfo.js.map +1 -1
- package/dist/esm/utils/isAddress.d.ts +1 -1
- package/dist/esm/utils/isAddress.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/chains/bitcoin.d.ts +2 -1
- package/dist/types/chains/bitcoin.d.ts.map +1 -1
- package/dist/types/chains/signet.d.ts +25 -0
- package/dist/types/chains/signet.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/address.d.ts +1 -5
- package/dist/types/types/address.d.ts.map +1 -1
- package/dist/types/types/chain.d.ts +16 -1
- package/dist/types/types/chain.d.ts.map +1 -1
- package/dist/types/utils/getAddressInfo.d.ts +2 -0
- package/dist/types/utils/getAddressInfo.d.ts.map +1 -1
- package/dist/types/utils/isAddress.d.ts +1 -1
- package/dist/types/utils/isAddress.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/package.json.tmp +1 -1
- package/src/chains/bitcoin.ts +2 -1
- package/src/chains/signet.spec.ts +33 -0
- package/src/chains/signet.ts +22 -0
- package/src/index.ts +9 -15
- package/src/types/address.ts +2 -6
- package/src/types/chain.ts +18 -1
- package/src/utils/getAddressInfo.ts +16 -1
- package/src/utils/isAddress.ts +2 -1
- package/src/version.ts +1 -1
- package/dist/cjs/errors/config.d.ts +0 -61
- package/dist/cjs/errors/config.js +0 -65
- package/dist/cjs/errors/config.js.map +0 -1
- package/dist/cjs/types/base.d.ts +0 -0
- package/dist/cjs/types/base.js +0 -2
- package/dist/cjs/types/base.js.map +0 -1
- package/dist/esm/errors/config.d.ts +0 -61
- package/dist/esm/errors/config.js +0 -55
- package/dist/esm/errors/config.js.map +0 -1
- package/dist/esm/types/base.d.ts +0 -0
- package/dist/esm/types/base.js +0 -2
- package/dist/esm/types/base.js.map +0 -1
- package/dist/types/errors/config.d.ts +0 -62
- package/dist/types/errors/config.d.ts.map +0 -1
- package/dist/types/types/base.d.ts +0 -1
- package/dist/types/types/base.d.ts.map +0 -1
- package/src/errors/config.ts +0 -102
- package/src/types/base.ts +0 -0
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
export declare enum ChainId {
|
|
2
|
+
BITCOIN_MAINNET = "bitcoin:mainnet",
|
|
3
|
+
BITCOIN_TESTNET = "bitcoin:testnet",
|
|
4
|
+
BITCOIN_TESTNET4 = "bitcoin:testnet4",
|
|
5
|
+
BITCOIN_SIGNET = "bitcoin:signet",
|
|
6
|
+
FRACTAL_BITCOIN_MAINNET = "fractal:mainnet",
|
|
7
|
+
FRACTAL_BITCOIN_TESTNET = "fractal:testnet",
|
|
8
|
+
STACKS_MAINNET = "stacks:mainnet",
|
|
9
|
+
STACKS_TESTNET = "stacks:testnet"
|
|
10
|
+
}
|
|
11
|
+
export declare enum Network {
|
|
12
|
+
Mainnet = "mainnet",
|
|
13
|
+
Testnet = "testnet",
|
|
14
|
+
Regtest = "regtest"
|
|
15
|
+
}
|
|
1
16
|
export type Chain<formatters extends ChainFormatters | undefined = ChainFormatters | undefined, custom extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = {
|
|
2
17
|
/** Collection of block explorers */
|
|
3
18
|
blockExplorers?: {
|
|
@@ -5,7 +20,7 @@ export type Chain<formatters extends ChainFormatters | undefined = ChainFormatte
|
|
|
5
20
|
default: ChainBlockExplorer;
|
|
6
21
|
} | undefined;
|
|
7
22
|
/** ID in number form */
|
|
8
|
-
id:
|
|
23
|
+
id: ChainId;
|
|
9
24
|
/** Human-readable name */
|
|
10
25
|
name: string;
|
|
11
26
|
/** Collection of RPC endpoints */
|
package/dist/esm/types/chain.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var ChainId;
|
|
2
|
+
(function (ChainId) {
|
|
3
|
+
ChainId["BITCOIN_MAINNET"] = "bitcoin:mainnet";
|
|
4
|
+
ChainId["BITCOIN_TESTNET"] = "bitcoin:testnet";
|
|
5
|
+
ChainId["BITCOIN_TESTNET4"] = "bitcoin:testnet4";
|
|
6
|
+
ChainId["BITCOIN_SIGNET"] = "bitcoin:signet";
|
|
7
|
+
ChainId["FRACTAL_BITCOIN_MAINNET"] = "fractal:mainnet";
|
|
8
|
+
ChainId["FRACTAL_BITCOIN_TESTNET"] = "fractal:testnet";
|
|
9
|
+
ChainId["STACKS_MAINNET"] = "stacks:mainnet";
|
|
10
|
+
ChainId["STACKS_TESTNET"] = "stacks:testnet";
|
|
11
|
+
})(ChainId || (ChainId = {}));
|
|
12
|
+
export var Network;
|
|
13
|
+
(function (Network) {
|
|
14
|
+
Network["Mainnet"] = "mainnet";
|
|
15
|
+
Network["Testnet"] = "testnet";
|
|
16
|
+
Network["Regtest"] = "regtest";
|
|
17
|
+
})(Network || (Network = {}));
|
|
2
18
|
//# sourceMappingURL=chain.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/types/chain.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/types/chain.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,OASX;AATD,WAAY,OAAO;IACjB,8CAAmC,CAAA;IACnC,8CAAmC,CAAA;IACnC,gDAAqC,CAAA;IACrC,4CAAiC,CAAA;IACjC,sDAA2C,CAAA;IAC3C,sDAA2C,CAAA;IAC3C,4CAAiC,CAAA;IACjC,4CAAiC,CAAA;AACnC,CAAC,EATW,OAAO,KAAP,OAAO,QASlB;AAED,MAAM,CAAN,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,8BAAmB,CAAA;IACnB,8BAAmB,CAAA;IACnB,8BAAmB,CAAA;AACrB,CAAC,EAJW,OAAO,KAAP,OAAO,QAIlB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha256';
|
|
2
2
|
import { bech32, bech32m } from 'bech32';
|
|
3
3
|
import bs58 from 'bs58';
|
|
4
|
-
import { AddressType,
|
|
4
|
+
import { AddressType, } from '../types/address.js';
|
|
5
|
+
import { ChainId, Network } from '../types/chain.js';
|
|
5
6
|
const addressTypes = {
|
|
6
7
|
0: {
|
|
7
8
|
type: AddressType.p2pkh,
|
|
@@ -117,4 +118,17 @@ const getAddressPurpose = (type) => {
|
|
|
117
118
|
throw new Error('Invalid address type');
|
|
118
119
|
}
|
|
119
120
|
};
|
|
121
|
+
export const getAddressChainId = (address) => {
|
|
122
|
+
const addressInfo = getAddressInfo(address);
|
|
123
|
+
switch (addressInfo.network) {
|
|
124
|
+
case Network.Mainnet:
|
|
125
|
+
return ChainId.BITCOIN_MAINNET;
|
|
126
|
+
case Network.Testnet:
|
|
127
|
+
return ChainId.BITCOIN_TESTNET;
|
|
128
|
+
case Network.Regtest:
|
|
129
|
+
return ChainId.BITCOIN_SIGNET;
|
|
130
|
+
default:
|
|
131
|
+
return ChainId.BITCOIN_MAINNET;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
120
134
|
//# sourceMappingURL=getAddressInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAddressInfo.js","sourceRoot":"","sources":["../../../src/utils/getAddressInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAgB,MAAM,QAAQ,CAAA;AACtD,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAIL,WAAW,
|
|
1
|
+
{"version":3,"file":"getAddressInfo.js","sourceRoot":"","sources":["../../../src/utils/getAddressInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAgB,MAAM,QAAQ,CAAA;AACtD,OAAO,IAAI,MAAM,MA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AI,CAAC;KAC7C,CAAA;AACH,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,IAAiB,EAAkB,EAAE;IAC9D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,WAAW,CAAC,IAAI;YACnB,OAAO,UAAU,CAAA;QACnB,KAAK,WAAW,CAAC,KAAK;YACpB,OAAO,QAAQ,CAAA;QACjB,KAAK,WAAW,CAAC,MAAM,CAAC;QACxB,KAAK,WAAW,CAAC,IAAI,CAAC;QACtB,KAAK,WAAW,CAAC,KAAK;YACpB,OAAO,SAAS,CAAA;QAClB;YACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IAC3C,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAgB,EAAW,EAAE;IAC7D,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;IAE3C,QAAQ,WAAW,CAAC,OAAO,EAAE,CAAC;QAC5B,KAAK,OAAO,CAAC,OAAO;YAClB,OAAO,OAAO,CAAC,eAAe,CAAA;QAChC,KAAK,OAAO,CAAC,OAAO;YAClB,OAAO,OAAO,CAAC,eAAe,CAAA;QAChC,KAAK,OAAO,CAAC,OAAO;YAClB,OAAO,OAAO,CAAC,cAAc,CAAA;QAC/B;YACE,OAAO,OAAO,CAAC,eAAe,CAAA;IAClC,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Network } from '../types/
|
|
1
|
+
import type { Network } from '../types/chain.js';
|
|
2
2
|
export declare const isAddress: (address: string, network?: Network) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAddress.js","sourceRoot":"","sources":["../../../src/utils/isAddress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isAddress.js","sourceRoot":"","sources":["../../../src/utils/isAddress.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,OAAiB,EAAW,EAAE;IACvE,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,cAAc,CAAC,OAAkB,CAAC,CAAA;QAEtD,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,OAAO,KAAK,WAAW,CAAC,OAAO,CAAA;QACxC,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA"}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@bigmi/core";
|
|
2
|
-
export declare const version = "0.
|
|
2
|
+
export declare const version = "0.5.1";
|
package/dist/esm/version.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChainId } from '../types/chain.js';
|
|
1
2
|
export declare const bitcoin: {
|
|
2
3
|
blockExplorers: {
|
|
3
4
|
readonly default: {
|
|
@@ -5,7 +6,7 @@ export declare const bitcoin: {
|
|
|
5
6
|
readonly url: "https://mempool.space/";
|
|
6
7
|
};
|
|
7
8
|
};
|
|
8
|
-
id:
|
|
9
|
+
id: ChainId.BITCOIN_MAINNET;
|
|
9
10
|
name: "Bitcoin";
|
|
10
11
|
rpcUrls: {
|
|
11
12
|
readonly default: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitcoin.d.ts","sourceRoot":"","sources":["../../../src/chains/bitcoin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bitcoin.d.ts","sourceRoot":"","sources":["../../../src/chains/bitcoin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAG3C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;CAelB,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChainId } from '../types/chain.js';
|
|
2
|
+
export declare const bitcoinSignet: {
|
|
3
|
+
blockExplorers: {
|
|
4
|
+
readonly default: {
|
|
5
|
+
readonly name: "Mempool";
|
|
6
|
+
readonly url: "https://mempool.space/signet";
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
id: ChainId.BITCOIN_SIGNET;
|
|
10
|
+
name: "Bitcoin Signet";
|
|
11
|
+
rpcUrls: {
|
|
12
|
+
readonly default: {
|
|
13
|
+
readonly http: readonly ["https://rpc.ankr.com/btc_signet/c58ee1c627c5ad7cd69197c352aa51bdcebd87b86e0363c1e5133d5735cb3c69"];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
testnet: true;
|
|
17
|
+
custom?: Record<string, unknown> | undefined;
|
|
18
|
+
formatters?: undefined;
|
|
19
|
+
readonly nativeCurrency: {
|
|
20
|
+
readonly name: "Bitcoin";
|
|
21
|
+
readonly symbol: "BTC";
|
|
22
|
+
readonly decimals: 8;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=signet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signet.d.ts","sourceRoot":"","sources":["../../../src/chains/signet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAG3C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;CAkBxB,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ export { type WalletActions, walletActions, } from './clients/decorators/wallet.
|
|
|
27
27
|
export { InvalidAddressError, type InvalidAddressErrorType, } from './errors/address.js';
|
|
28
28
|
export { BaseError, type BaseErrorType } from './errors/base.js';
|
|
29
29
|
export { BlockNotFoundError } from './errors/block.js';
|
|
30
|
-
export { ChainNotConfiguredError, ConnectorAccountNotFoundError, ConnectorAlreadyConnectedError, ConnectorChainMismatchError, ConnectorNotConnectedError, ConnectorNotFoundError, } from './errors/config.js';
|
|
31
30
|
export { ProviderNotFoundError } from './errors/provider.js';
|
|
32
31
|
export { HttpRequestError, RpcRequestError, SocketClosedError, TimeoutError, } from './errors/request.js';
|
|
33
32
|
export { MethodNotSupportedRpcError, ParseError, RpcErrorCode, UserRejectedRequestError, } from './errors/rpc.js';
|
|
@@ -54,10 +53,10 @@ export { mempoolMethods } from './transports/mempool/methods.js';
|
|
|
54
53
|
export type { ErrorResult, RpcMethodHandler, RpcMethods, RpcResponse, SignPsbtParameters, SignPsbtReturnType, SuccessResult, UTXOSchema, UTXOWalletSchema, } from './transports/types.js';
|
|
55
54
|
export { utxo } from './transports/utxo.js';
|
|
56
55
|
export type { Account } from './types/account.js';
|
|
57
|
-
export { type Address, type AddressInfo, type AddressPurpose, AddressType,
|
|
56
|
+
export { type Address, type AddressInfo, type AddressPurpose, AddressType, } from './types/address.js';
|
|
58
57
|
export type { BlockTag } from './types/block.js';
|
|
59
58
|
export type { BlockStats, BlockStatsKeys } from './types/blockStats.js';
|
|
60
|
-
export type
|
|
59
|
+
export { type Chain, type ChainConfig, type ChainFormatter, type ChainFormatters, ChainId, Network, } from './types/chain.js';
|
|
61
60
|
export type { Client, ClientConfig, CreateClientErrorType, } from './types/client.js';
|
|
62
61
|
export type { Hash } from './types/hash.js';
|
|
63
62
|
export type { BtcRpcRequestFn, BtcRpcRequestOptions, RpcParameters, RpcSchema, RpcSchemaOverride, } from './types/request.js';
|
|
@@ -68,7 +67,7 @@ export type { Assign, Compute, ExactPartial, IsNarrowable, IsNever, IsUnknown, L
|
|
|
68
67
|
export { cancelTransaction } from './utils/cancelTransaction.js';
|
|
69
68
|
export { base64ToHex, base64urlEncode, hexToBase64, hexToUnit8Array, stringToHex, } from './utils/converter.js';
|
|
70
69
|
export { deepEqual } from './utils/deepEqual.js';
|
|
71
|
-
export { getAddressInfo } from './utils/getAddressInfo.js';
|
|
70
|
+
export { getAddressChainId, getAddressInfo } from './utils/getAddressInfo.js';
|
|
72
71
|
export { isAddress as isUTXOAddress } from './utils/isAddress.js';
|
|
73
72
|
export { modifyFee } from './utils/modifyFee.js';
|
|
74
73
|
export { cleanupCache, listenersCache, observe } from './utils/observe.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,YAAY,EACV,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,YAAY,EACV,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,YAAY,EACV,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,YAAY,EACV,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,YAAY,EACV,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EACV,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,YAAY,EACV,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,QAA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payment' | 'ordinals' | 'stacks';
|
|
3
|
-
export declare enum Network {
|
|
4
|
-
Mainnet = "mainnet",
|
|
5
|
-
Testnet = "testnet",
|
|
6
|
-
Regtest = "regtest"
|
|
7
|
-
}
|
|
8
4
|
export declare enum AddressType {
|
|
9
5
|
p2pkh = "p2pkh",
|
|
10
6
|
p2sh = "p2sh",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/types/address.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE9D,oBAAY,
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/types/address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE9D,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,WAAW,CAAA;IACjB,OAAO,EAAE,cAAc,CAAA;CACxB,CAAA"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
export declare enum ChainId {
|
|
2
|
+
BITCOIN_MAINNET = "bitcoin:mainnet",
|
|
3
|
+
BITCOIN_TESTNET = "bitcoin:testnet",
|
|
4
|
+
BITCOIN_TESTNET4 = "bitcoin:testnet4",
|
|
5
|
+
BITCOIN_SIGNET = "bitcoin:signet",
|
|
6
|
+
FRACTAL_BITCOIN_MAINNET = "fractal:mainnet",
|
|
7
|
+
FRACTAL_BITCOIN_TESTNET = "fractal:testnet",
|
|
8
|
+
STACKS_MAINNET = "stacks:mainnet",
|
|
9
|
+
STACKS_TESTNET = "stacks:testnet"
|
|
10
|
+
}
|
|
11
|
+
export declare enum Network {
|
|
12
|
+
Mainnet = "mainnet",
|
|
13
|
+
Testnet = "testnet",
|
|
14
|
+
Regtest = "regtest"
|
|
15
|
+
}
|
|
1
16
|
export type Chain<formatters extends ChainFormatters | undefined = ChainFormatters | undefined, custom extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = {
|
|
2
17
|
/** Collection of block explorers */
|
|
3
18
|
blockExplorers?: {
|
|
@@ -5,7 +20,7 @@ export type Chain<formatters extends ChainFormatters | undefined = ChainFormatte
|
|
|
5
20
|
default: ChainBlockExplorer;
|
|
6
21
|
} | undefined;
|
|
7
22
|
/** ID in number form */
|
|
8
|
-
id:
|
|
23
|
+
id: ChainId;
|
|
9
24
|
/** Human-readable name */
|
|
10
25
|
name: string;
|
|
11
26
|
/** Collection of RPC endpoints */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/types/chain.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CACf,UAAU,SAAS,eAAe,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,EAC5E,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC9C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,SAAS,IACX;IACF,oCAAoC;IACpC,cAAc,CAAC,EACX;QACE,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAA;QACjC,OAAO,EAAE,kBAAkB,CAAA;KAC5B,GACD,SAAS,CAAA;IACb,wBAAwB;IACxB,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/types/chain.ts"],"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AAS,CAAA;IAC3B,8EAA8E;IAC9E,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAA;CACpC,CAAA;AAMD,MAAM,MAAM,eAAe,GAAG;IAC5B,6DAA6D;IAC7D,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA;IAC3C,mEAAmE;IACnE,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG,SAAS,CAAA;IACvD,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAA;IACrE,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAA;CACtE,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI;IACzD,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAA;IAC1B,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAMD,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IACvB,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CAC1C,CAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type Address, type AddressInfo } from '../types/address.js';
|
|
2
|
+
import { ChainId } from '../types/chain.js';
|
|
2
3
|
export declare const getAddressInfo: (address: Address) => AddressInfo;
|
|
4
|
+
export declare const getAddressChainId: (address: Address) => ChainId;
|
|
3
5
|
//# sourceMappingURL=getAddressInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAddressInfo.d.ts","sourceRoot":"","sources":["../../../src/utils/getAddressInfo.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"getAddressInfo.d.ts","sourceRoot":"","sources":["../../../src/utils/getAddressInfo.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,WAAW,EAGjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAW,MAAM,mBAAmB,CAAA;AA+EpD,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO,KAAG,WAiDjD,CAAA;AAiBD,eAAO,MAAM,iBAAiB,GAAI,SAAS,OAAO,KAAG,OAapD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAddress.d.ts","sourceRoot":"","sources":["../../../src/utils/isAddress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isAddress.d.ts","sourceRoot":"","sources":["../../../src/utils/isAddress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAGhD,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,OAY9D,CAAA"}
|
package/dist/types/version.d.ts
CHANGED
package/package.json
CHANGED
package/package.json.tmp
CHANGED
package/src/chains/bitcoin.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ChainId } from '../types/chain.js'
|
|
1
2
|
import { defineChain } from './defineChain.js'
|
|
2
3
|
|
|
3
4
|
export const bitcoin = /*#__PURE__*/ defineChain({
|
|
4
|
-
id:
|
|
5
|
+
id: ChainId.BITCOIN_MAINNET,
|
|
5
6
|
name: 'Bitcoin',
|
|
6
7
|
nativeCurrency: { name: 'Bitcoin', symbol: 'BTC', decimals: 8 },
|
|
7
8
|
rpcUrls: {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { getBalance } from '../actions/getBalance.js'
|
|
3
|
+
import { createClient, rpcSchema } from '../factories/createClient.js'
|
|
4
|
+
import { mempool } from '../transports/mempool/mempool.js'
|
|
5
|
+
import type { UTXOSchema } from '../transports/types.js'
|
|
6
|
+
import { bitcoinSignet } from './signet.js'
|
|
7
|
+
|
|
8
|
+
const shouldSkipIntegration = !process.env.ENABLE_INTEGRATION_TESTS
|
|
9
|
+
|
|
10
|
+
const TESTNET_ADDRESS =
|
|
11
|
+
'tb1p0d22lal2kve68h278yyqdl99cntymc9p37qd8uaj4ym7233c2k5s57m4sa'
|
|
12
|
+
|
|
13
|
+
describe('Real Testnet Integration', () => {
|
|
14
|
+
it.skipIf(shouldSkipIntegration)(
|
|
15
|
+
'should fetch real balance from testnet',
|
|
16
|
+
async () => {
|
|
17
|
+
const realTestnetClient = createClient({
|
|
18
|
+
chain: bitcoinSignet,
|
|
19
|
+
rpcSchema: rpcSchema<UTXOSchema>(),
|
|
20
|
+
transport: mempool({
|
|
21
|
+
baseUrl: 'https://mempool.space/signet/api',
|
|
22
|
+
}),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const balance = await getBalance(realTestnetClient, {
|
|
26
|
+
address: TESTNET_ADDRESS,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
expect(typeof balance).toBe('bigint')
|
|
30
|
+
expect(balance).toBeGreaterThanOrEqual(BigInt(0))
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ChainId } from '../types/chain.js'
|
|
2
|
+
import { defineChain } from './defineChain.js'
|
|
3
|
+
|
|
4
|
+
export const bitcoinSignet = /*#__PURE__*/ defineChain({
|
|
5
|
+
id: ChainId.BITCOIN_SIGNET,
|
|
6
|
+
name: 'Bitcoin Signet',
|
|
7
|
+
nativeCurrency: { name: 'Bitcoin', symbol: 'BTC', decimals: 8 },
|
|
8
|
+
rpcUrls: {
|
|
9
|
+
default: {
|
|
10
|
+
http: [
|
|
11
|
+
'https://rpc.ankr.com/btc_signet/c58ee1c627c5ad7cd69197c352aa51bdcebd87b86e0363c1e5133d5735cb3c69',
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
blockExplorers: {
|
|
16
|
+
default: {
|
|
17
|
+
name: 'Mempool',
|
|
18
|
+
url: 'https://mempool.space/signet',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
testnet: true,
|
|
22
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -72,14 +72,7 @@ export {
|
|
|
72
72
|
} from './errors/address.js'
|
|
73
73
|
export { BaseError, type BaseErrorType } from './errors/base.js'
|
|
74
74
|
export { BlockNotFoundError } from './errors/block.js'
|
|
75
|
-
|
|
76
|
-
ChainNotConfiguredError,
|
|
77
|
-
ConnectorAccountNotFoundError,
|
|
78
|
-
ConnectorAlreadyConnectedError,
|
|
79
|
-
ConnectorChainMismatchError,
|
|
80
|
-
ConnectorNotConnectedError,
|
|
81
|
-
ConnectorNotFoundError,
|
|
82
|
-
} from './errors/config.js'
|
|
75
|
+
|
|
83
76
|
export { ProviderNotFoundError } from './errors/provider.js'
|
|
84
77
|
export {
|
|
85
78
|
HttpRequestError,
|
|
@@ -162,15 +155,16 @@ export {
|
|
|
162
155
|
type AddressInfo,
|
|
163
156
|
type AddressPurpose,
|
|
164
157
|
AddressType,
|
|
165
|
-
Network,
|
|
166
158
|
} from './types/address.js'
|
|
167
159
|
export type { BlockTag } from './types/block.js'
|
|
168
160
|
export type { BlockStats, BlockStatsKeys } from './types/blockStats.js'
|
|
169
|
-
export
|
|
170
|
-
Chain,
|
|
171
|
-
ChainConfig,
|
|
172
|
-
ChainFormatter,
|
|
173
|
-
ChainFormatters,
|
|
161
|
+
export {
|
|
162
|
+
type Chain,
|
|
163
|
+
type ChainConfig,
|
|
164
|
+
type ChainFormatter,
|
|
165
|
+
type ChainFormatters,
|
|
166
|
+
ChainId,
|
|
167
|
+
Network,
|
|
174
168
|
} from './types/chain.js'
|
|
175
169
|
export type {
|
|
176
170
|
Client,
|
|
@@ -213,7 +207,7 @@ export {
|
|
|
213
207
|
stringToHex,
|
|
214
208
|
} from './utils/converter.js'
|
|
215
209
|
export { deepEqual } from './utils/deepEqual.js'
|
|
216
|
-
export { getAddressInfo } from './utils/getAddressInfo.js'
|
|
210
|
+
export { getAddressChainId, getAddressInfo } from './utils/getAddressInfo.js'
|
|
217
211
|
export { isAddress as isUTXOAddress } from './utils/isAddress.js'
|
|
218
212
|
export { modifyFee } from './utils/modifyFee.js'
|
|
219
213
|
export { cleanupCache, listenersCache, observe } from './utils/observe.js'
|
package/src/types/address.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
+
import type { Network } from './chain.js'
|
|
2
|
+
|
|
1
3
|
export type Address = string
|
|
2
4
|
|
|
3
5
|
export type AddressPurpose = 'payment' | 'ordinals' | 'stacks'
|
|
4
6
|
|
|
5
|
-
export enum Network {
|
|
6
|
-
Mainnet = 'mainnet',
|
|
7
|
-
Testnet = 'testnet',
|
|
8
|
-
Regtest = 'regtest',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
7
|
export enum AddressType {
|
|
12
8
|
p2pkh = 'p2pkh',
|
|
13
9
|
p2sh = 'p2sh',
|
package/src/types/chain.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
export enum ChainId {
|
|
2
|
+
BITCOIN_MAINNET = 'bitcoin:mainnet',
|
|
3
|
+
BITCOIN_TESTNET = 'bitcoin:testnet',
|
|
4
|
+
BITCOIN_TESTNET4 = 'bitcoin:testnet4',
|
|
5
|
+
BITCOIN_SIGNET = 'bitcoin:signet',
|
|
6
|
+
FRACTAL_BITCOIN_MAINNET = 'fractal:mainnet',
|
|
7
|
+
FRACTAL_BITCOIN_TESTNET = 'fractal:testnet',
|
|
8
|
+
STACKS_MAINNET = 'stacks:mainnet',
|
|
9
|
+
STACKS_TESTNET = 'stacks:testnet',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export enum Network {
|
|
13
|
+
Mainnet = 'mainnet',
|
|
14
|
+
Testnet = 'testnet',
|
|
15
|
+
Regtest = 'regtest',
|
|
16
|
+
}
|
|
17
|
+
|
|
1
18
|
export type Chain<
|
|
2
19
|
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
|
3
20
|
custom extends Record<string, unknown> | undefined =
|
|
@@ -12,7 +29,7 @@ export type Chain<
|
|
|
12
29
|
}
|
|
13
30
|
| undefined
|
|
14
31
|
/** ID in number form */
|
|
15
|
-
id:
|
|
32
|
+
id: ChainId
|
|
16
33
|
/** Human-readable name */
|
|
17
34
|
name: string
|
|
18
35
|
/** Collection of RPC endpoints */
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
type AddressInfo,
|
|
8
8
|
type AddressPurpose,
|
|
9
9
|
AddressType,
|
|
10
|
-
Network,
|
|
11
10
|
} from '../types/address.js'
|
|
11
|
+
import { ChainId, Network } from '../types/chain.js'
|
|
12
12
|
|
|
13
13
|
const addressTypes: {
|
|
14
14
|
[key: number]: { type: AddressType; network: Network }
|
|
@@ -152,3 +152,18 @@ const getAddressPurpose = (type: AddressType): AddressPurpose => {
|
|
|
152
152
|
throw new Error('Invalid address type')
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
|
|
156
|
+
export const getAddressChainId = (address: Address): ChainId => {
|
|
157
|
+
const addressInfo = getAddressInfo(address)
|
|
158
|
+
|
|
159
|
+
switch (addressInfo.network) {
|
|
160
|
+
case Network.Mainnet:
|
|
161
|
+
return ChainId.BITCOIN_MAINNET
|
|
162
|
+
case Network.Testnet:
|
|
163
|
+
return ChainId.BITCOIN_TESTNET
|
|
164
|
+
case Network.Regtest:
|
|
165
|
+
return ChainId.BITCOIN_SIGNET
|
|
166
|
+
default:
|
|
167
|
+
return ChainId.BITCOIN_MAINNET
|
|
168
|
+
}
|
|
169
|
+
}
|
package/src/utils/isAddress.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Address
|
|
1
|
+
import type { Address } from '../types/address.js'
|
|
2
|
+
import type { Network } from '../types/chain.js'
|
|
2
3
|
import { getAddressInfo } from './getAddressInfo.js'
|
|
3
4
|
|
|
4
5
|
export const isAddress = (address: string, network?: Network): boolean => {
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@bigmi/core'
|
|
2
|
-
export const version = '0.
|
|
2
|
+
export const version = '0.5.1'
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Address } from '../types/address.js';
|
|
2
|
-
import { BaseError } from './base.js';
|
|
3
|
-
export type ChainNotConfiguredErrorType = ChainNotConfiguredError & {
|
|
4
|
-
name: 'ChainNotConfiguredError';
|
|
5
|
-
};
|
|
6
|
-
export declare class ChainNotConfiguredError extends BaseError {
|
|
7
|
-
name: string;
|
|
8
|
-
constructor();
|
|
9
|
-
}
|
|
10
|
-
export type ConnectorAlreadyConnectedErrorType = ConnectorAlreadyConnectedError & {
|
|
11
|
-
name: 'ConnectorAlreadyConnectedError';
|
|
12
|
-
};
|
|
13
|
-
export declare class ConnectorAlreadyConnectedError extends BaseError {
|
|
14
|
-
name: string;
|
|
15
|
-
constructor();
|
|
16
|
-
}
|
|
17
|
-
export type ConnectorNotConnectedErrorType = ConnectorNotConnectedError & {
|
|
18
|
-
name: 'ConnectorNotConnectedError';
|
|
19
|
-
};
|
|
20
|
-
export declare class ConnectorNotConnectedError extends BaseError {
|
|
21
|
-
name: string;
|
|
22
|
-
constructor();
|
|
23
|
-
}
|
|
24
|
-
export type ConnectorNotFoundErrorType = ConnectorNotFoundError & {
|
|
25
|
-
name: 'ConnectorNotFoundError';
|
|
26
|
-
};
|
|
27
|
-
export declare class ConnectorNotFoundError extends BaseError {
|
|
28
|
-
name: string;
|
|
29
|
-
constructor();
|
|
30
|
-
}
|
|
31
|
-
export type ConnectorAccountNotFoundErrorType = ConnectorAccountNotFoundError & {
|
|
32
|
-
name: 'ConnectorAccountNotFoundError';
|
|
33
|
-
};
|
|
34
|
-
export declare class ConnectorAccountNotFoundError extends BaseError {
|
|
35
|
-
name: string;
|
|
36
|
-
constructor({ address, connector, }: {
|
|
37
|
-
address: Address;
|
|
38
|
-
connector: string;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
export type ConnectorChainMismatchErrorType = ConnectorAccountNotFoundError & {
|
|
42
|
-
name: 'ConnectorChainMismatchError';
|
|
43
|
-
};
|
|
44
|
-
export declare class ConnectorChainMismatchError extends BaseError {
|
|
45
|
-
name: string;
|
|
46
|
-
constructor({ connectionChainId, connectorChainId, }: {
|
|
47
|
-
connectionChainId: number;
|
|
48
|
-
connectorChainId: number;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
export type ConnectorUnavailableReconnectingErrorType = ConnectorUnavailableReconnectingError & {
|
|
52
|
-
name: 'ConnectorUnavailableReconnectingError';
|
|
53
|
-
};
|
|
54
|
-
export declare class ConnectorUnavailableReconnectingError extends BaseError {
|
|
55
|
-
name: string;
|
|
56
|
-
constructor({ connector }: {
|
|
57
|
-
connector: {
|
|
58
|
-
name: string;
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
}
|