@ickb/sdk 1000.0.52 → 1000.0.71
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/cjs/codec.d.ts +14 -0
- package/dist/cjs/codec.d.ts.map +1 -0
- package/dist/cjs/codec.js +125 -0
- package/dist/cjs/codec.js.map +1 -0
- package/dist/cjs/constants.d.ts +49 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +156 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -189
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +17 -338
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sdk.d.ts +178 -0
- package/dist/cjs/sdk.d.ts.map +1 -0
- package/dist/cjs/sdk.js +362 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/codec.d.ts +14 -0
- package/dist/esm/codec.d.ts.map +1 -0
- package/dist/esm/codec.js +122 -0
- package/dist/esm/codec.js.map +1 -0
- package/dist/esm/constants.d.ts +49 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +152 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +3 -189
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -336
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sdk.d.ts +178 -0
- package/dist/esm/sdk.d.ts.map +1 -0
- package/dist/esm/sdk.js +358 -0
- package/dist/esm/sdk.js.map +1 -0
- package/package.json +8 -8
- package/src/codec.ts +138 -0
- package/src/constants.ts +200 -0
- package/src/index.ts +3 -573
- package/src/sdk.ts +513 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { IckbUdtManager, LogicManager, OwnedOwnerManager } from "@ickb/core";
|
|
3
|
+
import { DaoManager } from "@ickb/dao";
|
|
4
|
+
import { OrderManager } from "@ickb/order";
|
|
5
|
+
import { CapacityManager, unique } from "@ickb/utils";
|
|
6
|
+
/**
|
|
7
|
+
* The iCKB UDT name.
|
|
8
|
+
*/
|
|
9
|
+
export const UDT_NAME = "iCKB";
|
|
10
|
+
/**
|
|
11
|
+
* The iCKB UDT symbol.
|
|
12
|
+
*/
|
|
13
|
+
export const UDT_SYMBOL = "iCKB";
|
|
14
|
+
/**
|
|
15
|
+
* The iCKB UDT number of decimals.
|
|
16
|
+
*/
|
|
17
|
+
export const UDT_DECIMALS = 8;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves the configuration for the given deployment environment.
|
|
20
|
+
*
|
|
21
|
+
* Accepts either a string identifier ("mainnet" or "testnet") or a custom configuration
|
|
22
|
+
* object containing script dependencies for a devnet.
|
|
23
|
+
*
|
|
24
|
+
* It sets up various managers (UDT, Logic, OwnedOwner, Order, Dao, Capacity) and also
|
|
25
|
+
* aggregates a unique list of known bot scripts.
|
|
26
|
+
*
|
|
27
|
+
* @param deps - Either a network identifier ("mainnet"/"testnet") or an object containing
|
|
28
|
+
* explicit script dependencies for devnet.
|
|
29
|
+
* @param bots - An optional array of bot script-like objects to augment the list of known bots.
|
|
30
|
+
* @returns An object containing the instantiated managers and bots.
|
|
31
|
+
*/
|
|
32
|
+
export function getConfig(deps, bots = []) {
|
|
33
|
+
// If deps is provided as a network string, use the pre-defined constants.
|
|
34
|
+
if (deps === "mainnet" || deps === "testnet") {
|
|
35
|
+
bots = bots.concat(deps === "mainnet" ? MAINNET_KNOWN_BOTS : TESTNET_KNOWN_BOTS);
|
|
36
|
+
const depGroup = deps === "mainnet" ? MAINNET_DEP_GROUP : TESTNET_DEP_GROUP;
|
|
37
|
+
deps = {
|
|
38
|
+
udt: from(UDT, depGroup),
|
|
39
|
+
ickbLogic: from(ICKB_LOGIC, depGroup),
|
|
40
|
+
ownedOwner: from(OWNED_OWNER, depGroup),
|
|
41
|
+
order: from(ORDER, depGroup),
|
|
42
|
+
dao: from(DAO, depGroup),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const daoManager = DaoManager.fromDeps(deps);
|
|
46
|
+
const ickbUdtManager = IckbUdtManager.fromDeps(deps, daoManager);
|
|
47
|
+
return {
|
|
48
|
+
managers: {
|
|
49
|
+
udt: ickbUdtManager,
|
|
50
|
+
ickbLogic: LogicManager.fromDeps(deps, daoManager, ickbUdtManager),
|
|
51
|
+
ownedOwner: OwnedOwnerManager.fromDeps(deps, daoManager, ickbUdtManager),
|
|
52
|
+
order: OrderManager.fromDeps(deps, ickbUdtManager),
|
|
53
|
+
dao: daoManager,
|
|
54
|
+
capacity: CapacityManager.withAnyData(),
|
|
55
|
+
},
|
|
56
|
+
bots: [...unique(bots.map((b) => ccc.Script.from(b)))],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Wraps a script-like object into a ScriptDeps structure.
|
|
61
|
+
*
|
|
62
|
+
* @param script - The script or script-like object.
|
|
63
|
+
* @param cellDeps - Additional cell dependencies that the script may require.
|
|
64
|
+
* @returns An object containing the script and its associated cell dependencies.
|
|
65
|
+
*/
|
|
66
|
+
function from(script, ...cellDeps) {
|
|
67
|
+
return {
|
|
68
|
+
script: ccc.Script.from(script),
|
|
69
|
+
cellDeps,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* UDT (User Defined Token) lock script information used for onchain validation.
|
|
74
|
+
*/
|
|
75
|
+
const UDT = {
|
|
76
|
+
codeHash: "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95",
|
|
77
|
+
hashType: "data1",
|
|
78
|
+
args: "0xb73b6ab39d79390c6de90a09c96b290c331baf1798ed6f97aed02590929734e800000080",
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* DAO (Decentralized Autonomous Organization) lock script information.
|
|
82
|
+
*/
|
|
83
|
+
const DAO = {
|
|
84
|
+
codeHash: "0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",
|
|
85
|
+
hashType: "type",
|
|
86
|
+
args: "0x",
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Logic script information for the iCKB logic contract.
|
|
90
|
+
*/
|
|
91
|
+
const ICKB_LOGIC = {
|
|
92
|
+
codeHash: "0x2a8100ab5990fa055ab1b50891702e1e895c7bd1df6322cd725c1a6115873bd3",
|
|
93
|
+
hashType: "data1",
|
|
94
|
+
args: "0x",
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* OwnedOwner lock script information.
|
|
98
|
+
*/
|
|
99
|
+
const OWNED_OWNER = {
|
|
100
|
+
codeHash: "0xacc79e07d107831feef4c70c9e683dac5644d5993b9cb106dca6e74baa381bd0",
|
|
101
|
+
hashType: "data1",
|
|
102
|
+
args: "0x",
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Order lock script information.
|
|
106
|
+
*/
|
|
107
|
+
const ORDER = {
|
|
108
|
+
codeHash: "0x49dfb6afee5cc8ac4225aeea8cb8928b150caf3cd92fea33750683c74b13254a",
|
|
109
|
+
hashType: "data1",
|
|
110
|
+
args: "0x",
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Mainnet dependency group cell dep.
|
|
114
|
+
*/
|
|
115
|
+
const MAINNET_DEP_GROUP = ccc.CellDep.from({
|
|
116
|
+
outPoint: {
|
|
117
|
+
txHash: "0x621a6f38de3b9f453016780edac3b26bfcbfa3e2ecb47c2da275471a5d3ed165",
|
|
118
|
+
index: "0x0",
|
|
119
|
+
},
|
|
120
|
+
depType: "depGroup",
|
|
121
|
+
});
|
|
122
|
+
/**
|
|
123
|
+
* Testnet dependency group cell dep.
|
|
124
|
+
*/
|
|
125
|
+
const TESTNET_DEP_GROUP = ccc.CellDep.from({
|
|
126
|
+
outPoint: {
|
|
127
|
+
txHash: "0xf7ece4fb33d8378344cab11fcd6a4c6f382fd4207ac921cf5821f30712dcd311",
|
|
128
|
+
index: "0x0",
|
|
129
|
+
},
|
|
130
|
+
depType: "depGroup",
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* Array of known bot scripts on the mainnet.
|
|
134
|
+
*/
|
|
135
|
+
const MAINNET_KNOWN_BOTS = [
|
|
136
|
+
{
|
|
137
|
+
codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
|
|
138
|
+
hashType: "type",
|
|
139
|
+
args: "0xd096cb29e2f68a85a46bd6bf6cbee6327959ba64",
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
/**
|
|
143
|
+
* Array of known bot scripts on the testnet.
|
|
144
|
+
*/
|
|
145
|
+
const TESTNET_KNOWN_BOTS = [
|
|
146
|
+
{
|
|
147
|
+
codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
|
|
148
|
+
hashType: "type",
|
|
149
|
+
args: "0xb4380110f7679ac31cefe4925485645d82bf619f",
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,EAAmB,MAAM,aAAa,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,MA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O,CAAC,IAAI,CAAC;IACzC,QAAQ,EAAE;QACR,MAAM,EACJ,oEAAoE;QACtE,KAAK,EAAE,KAAK;KACb;IACD,OAAO,EAAE,UAAU;CACpB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB;QACE,QAAQ,EACN,oEAAoE;QACtE,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,4CAA4C;KACnD;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB;QACE,QAAQ,EACN,oEAAoE;QACtE,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,4CAA4C;KACnD;CACF,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,190 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { DaoManager, type DaoCell } from "@ickb/dao";
|
|
5
|
-
import { OrderManager, type OrderCell, type OrderGroup } from "@ickb/order";
|
|
6
|
-
/**
|
|
7
|
-
* Controller for managing iCKB operations.
|
|
8
|
-
*/
|
|
9
|
-
export declare class IckbController {
|
|
10
|
-
readonly ickbUdtManager: IckbUdtManager;
|
|
11
|
-
readonly logicManager: LogicManager;
|
|
12
|
-
readonly ownedOwnerManager: OwnedOwnerManager;
|
|
13
|
-
readonly orderManager: OrderManager;
|
|
14
|
-
readonly daoManager: DaoManager;
|
|
15
|
-
readonly bots: ccc.Script[];
|
|
16
|
-
/**
|
|
17
|
-
* Creates an instance of IckbController.
|
|
18
|
-
* @param ickbUdtManager - The manager for iCKB UDT operations.
|
|
19
|
-
* @param logicManager - The logic manager for handling business logic.
|
|
20
|
-
* @param ownedOwnerManager - The manager for owned owner operations.
|
|
21
|
-
* @param orderManager - The manager for order operations.
|
|
22
|
-
* @param daoManager - The manager for DAO operations.
|
|
23
|
-
*/
|
|
24
|
-
constructor(ickbUdtManager: IckbUdtManager, logicManager: LogicManager, ownedOwnerManager: OwnedOwnerManager, orderManager: OrderManager, daoManager: DaoManager, bots: ccc.Script[]);
|
|
25
|
-
/**
|
|
26
|
-
* Creates an instance of IckbController from script dependencies.
|
|
27
|
-
* @param deps - The script dependencies.
|
|
28
|
-
* @param deps.udt - The script dependencies for UDT.
|
|
29
|
-
* @param deps.dao - The script dependencies for DAO.
|
|
30
|
-
* @param deps.ickbLogic - The script dependencies for iCKB logic.
|
|
31
|
-
* @param deps.ownedOwner - The script dependencies for owned owner.
|
|
32
|
-
* @param deps.order - The script dependencies for order.
|
|
33
|
-
* @returns An instance of IckbController.
|
|
34
|
-
*/
|
|
35
|
-
static fromDeps(deps: {
|
|
36
|
-
udt: ScriptDeps;
|
|
37
|
-
dao: ScriptDeps;
|
|
38
|
-
ickbLogic: ScriptDeps;
|
|
39
|
-
ownedOwner: ScriptDeps;
|
|
40
|
-
order: ScriptDeps;
|
|
41
|
-
}, bots: ccc.Script[]): IckbController;
|
|
42
|
-
/**
|
|
43
|
-
* Previews the conversion between CKB and UDT.
|
|
44
|
-
* @param conversion - The conversion parameters.
|
|
45
|
-
* @param conversion.isCkb2Udt - Indicates if the conversion is from CKB to UDT.
|
|
46
|
-
* @param conversion.amount - The amount to convert.
|
|
47
|
-
* @param conversion.rate - The exchange rate for conversion.
|
|
48
|
-
* @param conversion.fee - The fee for the conversion.
|
|
49
|
-
* @returns The rate and converted amount.
|
|
50
|
-
*
|
|
51
|
-
* Fee meaning examples:
|
|
52
|
-
* - 100000n => 0.001%
|
|
53
|
-
* - 10000n => 0.01%
|
|
54
|
-
* - 1000n => 0.1%
|
|
55
|
-
* - 100n => 1%
|
|
56
|
-
* - 10n => 10%
|
|
57
|
-
* - 1n => 100%
|
|
58
|
-
* - less than 1n => 0%
|
|
59
|
-
*/
|
|
60
|
-
static previewConversion(conversion: {
|
|
61
|
-
isCkb2Udt: boolean;
|
|
62
|
-
amount: ccc.FixedPoint;
|
|
63
|
-
rate: ExchangeRatio | ccc.ClientBlockHeader;
|
|
64
|
-
fee: ccc.Num;
|
|
65
|
-
}): {
|
|
66
|
-
rate: ExchangeRatio;
|
|
67
|
-
convertedAmount: ccc.FixedPoint;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Converts between CKB and UDT based on the provided options.
|
|
71
|
-
* @param options - The conversion options.
|
|
72
|
-
* @param options.conversion - The conversion parameters.
|
|
73
|
-
* @param options.conversion.isCkb2Udt - Indicates if the conversion is from CKB to UDT.
|
|
74
|
-
* @param options.conversion.amount - The amount to convert.
|
|
75
|
-
* @param options.conversion.rate - The exchange rate for conversion.
|
|
76
|
-
* @param options.conversion.ckbMinMatchLog - Minimum CKB match log (optional).
|
|
77
|
-
* @param options.conversion.ckbMinFee - Minimum CKB fee (optional).
|
|
78
|
-
* @param options.signer - The signer for the transaction.
|
|
79
|
-
* @param options.userCells - The user's cells.
|
|
80
|
-
* @param options.system - The current system state.
|
|
81
|
-
* @param options.filters - The filters for the conversion.
|
|
82
|
-
* @param options.filters.isReadyOnly - Indicates if only ready conversions should be considered.
|
|
83
|
-
* @param options.filters.isFulfilledOnly - Indicates if only fulfilled conversions should be considered.
|
|
84
|
-
* @returns A promise that resolves to the conversion result or undefined.
|
|
85
|
-
*/
|
|
86
|
-
convert(options: {
|
|
87
|
-
conversion: Parameters<typeof IckbController.previewConversion>[0] & {
|
|
88
|
-
ckbMinMatchLog?: number;
|
|
89
|
-
ckbMinFee?: ccc.Num;
|
|
90
|
-
};
|
|
91
|
-
signer: ccc.Signer;
|
|
92
|
-
userCells: UserCells;
|
|
93
|
-
system: SystemState;
|
|
94
|
-
filters: {
|
|
95
|
-
isReadyOnly: boolean;
|
|
96
|
-
isFulfilledOnly: boolean;
|
|
97
|
-
};
|
|
98
|
-
}): Promise<Conversion | undefined>;
|
|
99
|
-
/**
|
|
100
|
-
* Attempts to perform a conversion based on the provided parameters.
|
|
101
|
-
* @param n - The size of deposit to make or withdraw from.
|
|
102
|
-
* @param conversion - The conversion parameters.
|
|
103
|
-
* @param conversion.isCkb2Udt - Indicates if the conversion is from CKB to UDT.
|
|
104
|
-
* @param conversion.amount - The amount to convert.
|
|
105
|
-
* @param conversion.rate - The exchange rate for conversion.
|
|
106
|
-
* @param conversion.info - Additional information for the conversion.
|
|
107
|
-
* @param conversion.ckbMinFee - Minimum CKB fee.
|
|
108
|
-
* @param conversion.lock - The script lock for the transaction.
|
|
109
|
-
* @param options - Additional options for the conversion.
|
|
110
|
-
* @returns A promise that resolves to the conversion result or undefined.
|
|
111
|
-
*/
|
|
112
|
-
private attempt;
|
|
113
|
-
/**
|
|
114
|
-
* Retrieves the L1 state based on the provided parameters.
|
|
115
|
-
* @param client - The client to interact with the blockchain.
|
|
116
|
-
* @param filter - The set of filters to apply.
|
|
117
|
-
* @param locks - The script locks to filter the user cells.
|
|
118
|
-
* @param options - Optional parameters for the state retrieval.
|
|
119
|
-
* @param options.minLockUp - The minimum lock-up period (optional).
|
|
120
|
-
* @param options.maxLockUp - The maximum lock-up period (optional).
|
|
121
|
-
* @returns A promise that resolves to an object containing the system state and user cells.
|
|
122
|
-
*/
|
|
123
|
-
getL1State(client: ccc.Client, filter: Set<keyof UserCells | "depositPool" | "ckbBots">, locks: ccc.Script[], options?: {
|
|
124
|
-
minLockUp?: ccc.Epoch;
|
|
125
|
-
maxLockUp?: ccc.Epoch;
|
|
126
|
-
}): Promise<{
|
|
127
|
-
system: SystemState;
|
|
128
|
-
user: UserCells;
|
|
129
|
-
}>;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Represents the state of the system.
|
|
133
|
-
*/
|
|
134
|
-
export interface SystemState {
|
|
135
|
-
/** The fee rate for transactions. */
|
|
136
|
-
feeRate: ccc.Num;
|
|
137
|
-
/** The tip for the current block header. */
|
|
138
|
-
tip: ccc.ClientBlockHeader;
|
|
139
|
-
/** The exchange ratio between CKB and UDT. */
|
|
140
|
-
exchangeRatio: ExchangeRatio;
|
|
141
|
-
/** The deposit cap expressed in CKB. */
|
|
142
|
-
ckbDepositCap: ccc.FixedPoint;
|
|
143
|
-
/** The deposit cap expressed in iCKB. */
|
|
144
|
-
udtDepositCap: ccc.FixedPoint;
|
|
145
|
-
/**
|
|
146
|
-
* The deposit pool containing iCKB deposit cells with cumulative iCKB amounts.
|
|
147
|
-
*/
|
|
148
|
-
depositPool: (IckbDepositCell & {
|
|
149
|
-
udtCumulative: bigint;
|
|
150
|
-
})[];
|
|
151
|
-
/**
|
|
152
|
-
* The order pool containing non-user order cells.
|
|
153
|
-
*/
|
|
154
|
-
orderPool: OrderCell[];
|
|
155
|
-
/**
|
|
156
|
-
* The ckb held by bots ready to match incoming iCKB to CKB conversions.
|
|
157
|
-
*/
|
|
158
|
-
ckbBots: ccc.FixedPoint;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Represents the user cells in the system.
|
|
162
|
-
*/
|
|
163
|
-
export interface UserCells {
|
|
164
|
-
/** The capacities owned by the user. */
|
|
165
|
-
capacities: CapacityCell[];
|
|
166
|
-
/** The UDTs owned by the user. */
|
|
167
|
-
udts: UdtCell[];
|
|
168
|
-
/** The receipts associated with the user's transactions. */
|
|
169
|
-
receipts: ReceiptCell[];
|
|
170
|
-
/** The withdrawal groups for the user. */
|
|
171
|
-
withdrawalGroups: WithdrawalGroup[];
|
|
172
|
-
/** The orders placed by the user. */
|
|
173
|
-
orders: OrderGroup[];
|
|
174
|
-
/** The classical/non-iCKB deposits made by the user. */
|
|
175
|
-
deposits: DaoCell[];
|
|
176
|
-
/** The classical/non-iCKB withdrawal requests made by the user. */
|
|
177
|
-
withdrawalRequests: DaoCell[];
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Represents a conversion transaction.
|
|
181
|
-
*/
|
|
182
|
-
export interface Conversion {
|
|
183
|
-
/** The smart transaction associated with the conversion. */
|
|
184
|
-
tx: SmartTransaction;
|
|
185
|
-
/** The fee in CKB for the order created by the conversion. */
|
|
186
|
-
ckbFee: ccc.FixedPoint;
|
|
187
|
-
/** The estimated maturity epoch for conversion. */
|
|
188
|
-
maturity: ccc.Epoch;
|
|
189
|
-
}
|
|
1
|
+
export * from "./sdk.js";
|
|
2
|
+
export * from "./codec.js";
|
|
3
|
+
export * from "./constants.js";
|
|
190
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|