@ickb/sdk 9000.0.1 → 9001.0.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 +14 -11
- package/dist/constants.d.ts +0 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -24
- package/dist/constants.js.map +1 -1
- package/dist/conversion/estimate.d.ts +0 -6
- package/dist/conversion/estimate.d.ts.map +1 -1
- package/dist/conversion/estimate.js +1 -1
- package/dist/conversion/estimate.js.map +1 -1
- package/dist/conversion/maturity.d.ts +1 -1
- package/dist/conversion/maturity.js +13 -12
- package/dist/conversion/maturity.js.map +1 -1
- package/dist/conversion/plans.d.ts.map +1 -1
- package/dist/conversion/plans.js +6 -6
- package/dist/conversion/plans.js.map +1 -1
- package/dist/conversion/projection.d.ts +5 -6
- package/dist/conversion/projection.d.ts.map +1 -1
- package/dist/conversion/projection.js +11 -8
- package/dist/conversion/projection.js.map +1 -1
- package/dist/conversion/types.d.ts +29 -17
- package/dist/conversion/types.d.ts.map +1 -1
- package/dist/conversion/withdrawal_ring.d.ts +1 -3
- package/dist/conversion/withdrawal_ring.d.ts.map +1 -1
- package/dist/conversion/withdrawal_ring.js +4 -4
- package/dist/conversion/withdrawal_ring.js.map +1 -1
- package/dist/dao.d.ts +19 -5
- package/dist/dao.d.ts.map +1 -1
- package/dist/dao.js +24 -12
- package/dist/dao.js.map +1 -1
- package/dist/index.d.ts +9 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/logic.d.ts +10 -14
- package/dist/logic.d.ts.map +1 -1
- package/dist/logic.js +28 -39
- package/dist/logic.js.map +1 -1
- package/dist/order/cells.d.ts +10 -49
- package/dist/order/cells.d.ts.map +1 -1
- package/dist/order/cells.js +28 -146
- package/dist/order/cells.js.map +1 -1
- package/dist/order/conversion.d.ts +3 -9
- package/dist/order/conversion.d.ts.map +1 -1
- package/dist/order/conversion.js +8 -11
- package/dist/order/conversion.js.map +1 -1
- package/dist/order/fill.d.ts +2 -2
- package/dist/order/fill.js +3 -3
- package/dist/order/fill.js.map +1 -1
- package/dist/order/info.d.ts.map +1 -1
- package/dist/order/info.js +3 -0
- package/dist/order/info.js.map +1 -1
- package/dist/order/matcher.d.ts +1 -1
- package/dist/order/matcher.d.ts.map +1 -1
- package/dist/order/matcher.js +3 -2
- package/dist/order/matcher.js.map +1 -1
- package/dist/order/order.d.ts +6 -2
- package/dist/order/order.d.ts.map +1 -1
- package/dist/order/order.js +32 -37
- package/dist/order/order.js.map +1 -1
- package/dist/order/order_data.d.ts.map +1 -1
- package/dist/order/order_data.js +3 -0
- package/dist/order/order_data.js.map +1 -1
- package/dist/order/ratio.d.ts +0 -2
- package/dist/order/ratio.d.ts.map +1 -1
- package/dist/order/ratio.js +3 -11
- package/dist/order/ratio.js.map +1 -1
- package/dist/order/relative.d.ts.map +1 -1
- package/dist/order/relative.js +3 -0
- package/dist/order/relative.js.map +1 -1
- package/dist/owned_owner.d.ts +10 -15
- package/dist/owned_owner.d.ts.map +1 -1
- package/dist/owned_owner.js +27 -47
- package/dist/owned_owner.js.map +1 -1
- package/dist/sdk.d.ts +74 -31
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +81 -59
- package/dist/sdk.js.map +1 -1
- package/dist/send/sign_and_send_transaction.d.ts +32 -17
- package/dist/send/sign_and_send_transaction.d.ts.map +1 -1
- package/dist/send/sign_and_send_transaction.js +128 -28
- package/dist/send/sign_and_send_transaction.js.map +1 -1
- package/dist/send/wait_transaction.d.ts +7 -6
- package/dist/send/wait_transaction.d.ts.map +1 -1
- package/dist/send/wait_transaction.js +29 -61
- package/dist/send/wait_transaction.js.map +1 -1
- package/dist/udt.d.ts +20 -35
- package/dist/udt.d.ts.map +1 -1
- package/dist/udt.js +39 -103
- package/dist/udt.js.map +1 -1
- package/dist/utils/chain.d.ts +0 -35
- package/dist/utils/chain.d.ts.map +1 -1
- package/dist/utils/chain.js +1 -19
- package/dist/utils/chain.js.map +1 -1
- package/dist/utils/codec.d.ts.map +1 -1
- package/dist/utils/codec.js +3 -0
- package/dist/utils/codec.js.map +1 -1
- package/dist/utils/utils.d.ts +19 -46
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +53 -74
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/verified_client.d.ts +19 -0
- package/dist/utils/verified_client.d.ts.map +1 -0
- package/dist/utils/verified_client.js +92 -0
- package/dist/utils/verified_client.js.map +1 -0
- package/package.json +2 -2
- package/src/constants.ts +6 -25
- package/src/conversion/estimate.ts +1 -3
- package/src/conversion/maturity.ts +13 -14
- package/src/conversion/plans.ts +6 -6
- package/src/conversion/projection.ts +15 -7
- package/src/conversion/types.ts +32 -17
- package/src/conversion/withdrawal_ring.ts +4 -8
- package/src/dao.ts +38 -14
- package/src/index.ts +8 -8
- package/src/logic.ts +40 -52
- package/src/order/cells.ts +37 -174
- package/src/order/conversion.ts +8 -19
- package/src/order/fill.ts +3 -3
- package/src/order/info.ts +3 -0
- package/src/order/matcher.ts +3 -3
- package/src/order/order.ts +38 -52
- package/src/order/order_data.ts +3 -0
- package/src/order/ratio.ts +3 -20
- package/src/order/relative.ts +3 -0
- package/src/owned_owner.ts +47 -77
- package/src/sdk.ts +95 -108
- package/src/send/sign_and_send_transaction.ts +164 -28
- package/src/send/wait_transaction.ts +44 -88
- package/src/udt.ts +56 -124
- package/src/utils/chain.ts +0 -41
- package/src/utils/codec.ts +4 -0
- package/src/utils/utils.ts +76 -105
- package/src/utils/verified_client.ts +136 -0
- package/dist/utils/transaction_header.d.ts +0 -17
- package/dist/utils/transaction_header.d.ts.map +0 -1
- package/dist/utils/transaction_header.js +0 -44
- package/dist/utils/transaction_header.js.map +0 -1
- package/src/utils/transaction_header.ts +0 -66
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign_and_send_transaction.js","sourceRoot":"","sources":["../../src/send/sign_and_send_transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sign_and_send_transaction.js","sourceRoot":"","sources":["../../src/send/sign_and_send_transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,WAAW,EAA0B,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,+FAA+F;AAC/F,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,oFAAoF;IACpE,MAAM,CAAU;IAEhC,iDAAiD;IACjD,YAAY,MAAe,EAAE,OAAqB;QAChD,KAAK,CAAC,eAAe,MAAM,kCAAkC,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,gGAAgG;AAChG,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,sDAAsD;IACtC,MAAM,CAAiD;IAEvE,8EAA8E;IAC9E,YACE,MAAsD,EACtD,OAAsB;QAEtB,KAAK,CAAC,+DAA+D,EAAE,OAAO,CAAC,CAAC;QAChF,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAkB,EAClB,EAAuB,EACvB,UAAmB,EACnB,YAAwC,EACxC,eAAmC;IAEnC,qFAAqF;IACrF,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IACnD,MAAM,aA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jC,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,GAAG,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAChF,QAAQ,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,QAAQ,KAAK,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,MAAM,CAAC,gBAAgB,CAAC;AACxF,CAAC;AAED,iFAAiF;AACjF,8EAA8E;AAC9E,8DAA8D;AAC9D,SAAS,YAAY,CAAC,EAAuB;IAC3C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAkB,EAClB,WAAuB;IAEvB,OAAO;QACL,GAAG,MAAM,CAAC;YACR,WAAW;YACX,GAAG,CAAC,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC;SAC/D,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -23,19 +23,20 @@ export interface WaitTransactionOptions {
|
|
|
23
23
|
signal?: AbortSignal;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Observes one already-broadcast transaction for a single bounded window and
|
|
27
|
-
*
|
|
26
|
+
* Observes one already-broadcast transaction for a single bounded window and resolves
|
|
27
|
+
* once the node reports it committed.
|
|
28
28
|
*
|
|
29
29
|
* @remarks Stack waits at depth zero. Actors rebuild next turn; the app can reopen a
|
|
30
30
|
* window on the same hash without signing again. Callers needing deeper confirmation
|
|
31
31
|
* must observe it separately.
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* The status is polled with raw `get_transaction` verbosity 1, since CCC's typed response
|
|
33
|
+
* discards a null transaction body and its rejection status; the client must be JSON-RPC,
|
|
34
|
+
* the connector's composed client included. The body is never read: no caller uses it,
|
|
35
|
+
* and the same node's word on it would verify nothing.
|
|
35
36
|
* Timeout and abort also apply while awaiting client
|
|
36
37
|
* operations, but the in-flight client operation receives no abort signal and may
|
|
37
38
|
* finish after this function rejects. Nothing here mutates the client cache: later attempts rebuild
|
|
38
39
|
* from exact committed reads.
|
|
39
40
|
*/
|
|
40
|
-
export declare function waitTransaction(client: ccc.Client, txHashLike: ccc.HexLike, options?: WaitTransactionOptions): Promise<
|
|
41
|
+
export declare function waitTransaction(client: ccc.Client, txHashLike: ccc.HexLike, options?: WaitTransactionOptions): Promise<void>;
|
|
41
42
|
//# sourceMappingURL=wait_transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait_transaction.d.ts","sourceRoot":"","sources":["../../src/send/wait_transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,iFAAiF;AACjF,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,8DAA8D;IAC9D,SAAgB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;IAChC,4CAA4C;IAC5C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,sDAAsD;IACtD,SAAgB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAE3C,yEAAyE;IACzE,YACE,MAAM,EAAE,GAAG,CAAC,GAAG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AI,CAAC,CA6Bf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { jsonRpcRequestor
|
|
2
|
+
import { jsonRpcRequestor } from "../utils/utils.js";
|
|
3
3
|
const MAX_TIMEOUT_MS = 2_147_483_647;
|
|
4
4
|
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
5
5
|
const DEFAULT_INTERVAL_MS = 2_000;
|
|
@@ -23,15 +23,16 @@ export class TransactionWaitError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Observes one already-broadcast transaction for a single bounded window and
|
|
27
|
-
*
|
|
26
|
+
* Observes one already-broadcast transaction for a single bounded window and resolves
|
|
27
|
+
* once the node reports it committed.
|
|
28
28
|
*
|
|
29
29
|
* @remarks Stack waits at depth zero. Actors rebuild next turn; the app can reopen a
|
|
30
30
|
* window on the same hash without signing again. Callers needing deeper confirmation
|
|
31
31
|
* must observe it separately.
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* The status is polled with raw `get_transaction` verbosity 1, since CCC's typed response
|
|
33
|
+
* discards a null transaction body and its rejection status; the client must be JSON-RPC,
|
|
34
|
+
* the connector's composed client included. The body is never read: no caller uses it,
|
|
35
|
+
* and the same node's word on it would verify nothing.
|
|
35
36
|
* Timeout and abort also apply while awaiting client
|
|
36
37
|
* operations, but the in-flight client operation receives no abort signal and may
|
|
37
38
|
* finish after this function rejects. Nothing here mutates the client cache: later attempts rebuild
|
|
@@ -45,15 +46,13 @@ export async function waitTransaction(client, txHashLike, options = {}) {
|
|
|
45
46
|
const txHash = ccc.hexFrom(txHashLike);
|
|
46
47
|
signal?.throwIfAborted();
|
|
47
48
|
const budget = openWaitWindow(timeout, signal);
|
|
48
|
-
const poll = { client, txHash, budget };
|
|
49
49
|
try {
|
|
50
50
|
for (;;) {
|
|
51
|
-
|
|
52
|
-
if (committed !== undefined) {
|
|
51
|
+
if (await isCommitted(client, txHash, budget)) {
|
|
53
52
|
// An abort synchronized into the gap between the last read and this
|
|
54
53
|
// return must not resolve the wait successfully.
|
|
55
54
|
budget.throwIfStopped();
|
|
56
|
-
return
|
|
55
|
+
return;
|
|
57
56
|
}
|
|
58
57
|
if (Date.now() + interval >= budget.deadline) {
|
|
59
58
|
throw budget.timeoutError;
|
|
@@ -146,59 +145,28 @@ async function pollingSleep(interval, budget) {
|
|
|
146
145
|
clearTimeout(timer);
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
|
-
async function
|
|
150
|
-
const status = await readTransactionStatus(poll);
|
|
151
|
-
assertNotRejected(poll.txHash, status);
|
|
152
|
-
if (status.status !== "committed") {
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
const response = status.response ?? (await readTransactionBody(poll));
|
|
156
|
-
if (response === undefined) {
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
assertNotRejected(poll.txHash, {
|
|
160
|
-
status: response.status,
|
|
161
|
-
reason: response.reason,
|
|
162
|
-
});
|
|
163
|
-
// Only a body that itself reports commitment counts: an uncached read may lag
|
|
164
|
-
// or disagree with the status poll, and any other status is not commitment.
|
|
165
|
-
return response.status === "committed" && response.blockNumber !== undefined
|
|
166
|
-
? response
|
|
167
|
-
: undefined;
|
|
168
|
-
}
|
|
169
|
-
async function readTransactionStatus(poll) {
|
|
170
|
-
const { client, txHash, budget } = poll;
|
|
148
|
+
async function isCommitted(client, txHash, budget) {
|
|
171
149
|
const requestor = jsonRpcRequestor(client);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const response = await readTransactionBody(poll);
|
|
178
|
-
return response === undefined
|
|
179
|
-
? { status: undefined, reason: undefined }
|
|
180
|
-
: { status: response.status, reason: response.reason, response };
|
|
181
|
-
}
|
|
182
|
-
async function readTransactionBody(poll) {
|
|
183
|
-
const response = await within(async () => poll.client.getTransactionNoCache(poll.txHash), poll.budget);
|
|
184
|
-
if (response === undefined) {
|
|
185
|
-
return undefined;
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
// A generic client may return an unvalidated shape, and a body that cannot
|
|
189
|
-
// be normalized is not evidence of commitment: keep the window polling.
|
|
190
|
-
return ccc.ClientTransactionResponse.from(response);
|
|
191
|
-
}
|
|
192
|
-
catch {
|
|
193
|
-
return undefined;
|
|
150
|
+
// Raw verbosity-1 polling keeps a status-only rejection that CCC's typed transaction
|
|
151
|
+
// response discards (its body is null, so CCC returns nothing).
|
|
152
|
+
const { status, reason } = rawTransactionStatus(await within(async () => requestor.request("get_transaction", [txHash, "0x1"]), budget));
|
|
153
|
+
if (status === "rejected") {
|
|
154
|
+
throw new TransactionWaitError(txHash, { status, reason });
|
|
194
155
|
}
|
|
156
|
+
return status === "committed";
|
|
195
157
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
158
|
+
/** A node's raw `get_transaction` status record (verbosity 1), the fields read here. */
|
|
159
|
+
function rawTransactionStatus(response) {
|
|
160
|
+
const record = typeof response === "object" &&
|
|
161
|
+
response !== null &&
|
|
162
|
+
"tx_status" in response &&
|
|
163
|
+
typeof response.tx_status === "object" &&
|
|
164
|
+
response.tx_status !== null
|
|
165
|
+
? response.tx_status
|
|
166
|
+
: {};
|
|
167
|
+
return {
|
|
168
|
+
status: "status" in record && typeof record.status === "string" ? record.status : undefined,
|
|
169
|
+
reason: "reason" in record && typeof record.reason === "string" ? record.reason : undefined,
|
|
170
|
+
};
|
|
203
171
|
}
|
|
204
172
|
//# sourceMappingURL=wait_transaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait_transaction.js","sourceRoot":"","sources":["../../src/send/wait_transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,gBAAgB,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*/
|
|
32
32
|
readonly script: ccc.Script;
|
|
33
|
-
/**
|
|
34
|
-
readonly
|
|
35
|
-
/** Out point of the iCKB Logic code cell required by this token. */
|
|
36
|
-
readonly logicCode: ccc.OutPoint;
|
|
33
|
+
/** The iCKB dep group, which also carries the xUDT and iCKB Logic code cells. */
|
|
34
|
+
readonly cellDeps: ccc.CellDep[];
|
|
37
35
|
/** Logic script whose hash is embedded in this iCKB xUDT type script. */
|
|
38
36
|
readonly logicScript: ccc.Script;
|
|
39
37
|
/** The Nervos DAO script, to recognize the first-phase deposits a transaction re-mints. */
|
|
40
38
|
readonly daoScript: ccc.Script;
|
|
41
39
|
/** Creates an instance of IckbUdt from its code and script references. */
|
|
42
|
-
constructor({
|
|
43
|
-
code: ccc.OutPointLike;
|
|
40
|
+
constructor({ script, cellDeps, logicScript, daoScript, }: {
|
|
44
41
|
script: ccc.ScriptLike;
|
|
45
|
-
|
|
42
|
+
cellDeps: ccc.CellDepLike[];
|
|
46
43
|
logicScript: ccc.ScriptLike;
|
|
47
44
|
daoScript: ccc.ScriptLike;
|
|
48
45
|
});
|
|
@@ -66,26 +63,14 @@ export declare class IckbUdt {
|
|
|
66
63
|
*/
|
|
67
64
|
isUdt(cellLike: ccc.CellAnyLike): boolean;
|
|
68
65
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* - iCKB Logic code cell (this.logicCode)
|
|
74
|
-
*
|
|
75
|
-
* @param txLike - The transaction to add cell deps to.
|
|
76
|
-
* @returns The transaction with cell deps added.
|
|
77
|
-
*/
|
|
78
|
-
addCellDeps(txLike: ccc.TransactionLike): ccc.Transaction;
|
|
79
|
-
/**
|
|
80
|
-
* iCKB carried by the transaction's inputs: xUDT balances plus receipt value,
|
|
81
|
-
* minus the first-phase deposits it re-mints. Final withdrawal inputs carry none.
|
|
82
|
-
* The protocol cells are valued at their deposit headers, each read once.
|
|
66
|
+
* iCKB carried by the transaction's inputs: xUDT balances plus receipt value, minus the
|
|
67
|
+
* first-phase deposits it re-mints. Receipts and deposits take the value the state read
|
|
68
|
+
* gave them at their deposit headers; a protocol input missing from `protocolCells` is
|
|
69
|
+
* a builder bug and throws, since iCKB Logic would refuse whatever it was valued at.
|
|
83
70
|
*/
|
|
84
|
-
inputBalance(tx: ccc.Transaction, client: ccc.Client): Promise<ccc.Num>;
|
|
85
|
-
/**
|
|
86
|
-
private
|
|
87
|
-
/** iCKB the transaction's outputs require. */
|
|
88
|
-
outputBalance(tx: ccc.Transaction): ccc.Num;
|
|
71
|
+
inputBalance(tx: ccc.Transaction, client: ccc.Client, protocolCells: readonly ProtocolCell[]): Promise<ccc.Num>;
|
|
72
|
+
/** 1 for a receipt, -1 for a first-phase iCKB deposit, 0 for any other cell. */
|
|
73
|
+
private protocolSign;
|
|
89
74
|
/** Adds the iCKB change output when the surplus is positive; zero needs no output. */
|
|
90
75
|
addChange(tx: ccc.Transaction, lock: ccc.ScriptLike, balance: ccc.Num): void;
|
|
91
76
|
}
|
|
@@ -97,15 +82,10 @@ export declare class IckbUdt {
|
|
|
97
82
|
* excess amount.
|
|
98
83
|
*/
|
|
99
84
|
export declare function ickbValue(ckbUnoccupiedCapacity: ccc.FixedPoint, header: ccc.ClientBlockHeader): ccc.FixedPoint;
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* @param amount - The amount to convert.
|
|
105
|
-
* @param ratio - The CKB and iCKB scales to use.
|
|
106
|
-
* @returns The converted amount in the target unit as a `ccc.FixedPoint`.
|
|
107
|
-
*/
|
|
108
|
-
export declare function convert(isCkb2Udt: boolean, amount: ccc.FixedPoint, ratio: ExchangeRatio): ccc.FixedPoint;
|
|
85
|
+
/** The iCKB worth `amount` CKB at `ratio`, rounded down. */
|
|
86
|
+
export declare function udtFromCkb(amount: ccc.FixedPoint, ratio: ExchangeRatio): ccc.FixedPoint;
|
|
87
|
+
/** The CKB worth `amount` iCKB at `ratio`, rounded down. */
|
|
88
|
+
export declare function ckbFromUdt(amount: ccc.FixedPoint, ratio: ExchangeRatio): ccc.FixedPoint;
|
|
109
89
|
/**
|
|
110
90
|
* Calculates the free-capacity accounting ratio at a block header.
|
|
111
91
|
*
|
|
@@ -120,4 +100,9 @@ export declare function ickbAccountingRatio(header: ccc.ClientBlockHeader): Exch
|
|
|
120
100
|
* over the 100,000 iCKB reference amount.
|
|
121
101
|
*/
|
|
122
102
|
export declare function ickbExchangeRatio(header: ccc.ClientBlockHeader): ExchangeRatio;
|
|
103
|
+
/** A receipt or iCKB deposit with the iCKB value the state read gave it. */
|
|
104
|
+
export interface ProtocolCell {
|
|
105
|
+
cell: ccc.Cell;
|
|
106
|
+
udtValue: ccc.Num;
|
|
107
|
+
}
|
|
123
108
|
//# sourceMappingURL=udt.d.ts.map
|
package/dist/udt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"udt.d.ts","sourceRoot":"","sources":["../src/udt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"udt.d.ts","sourceRoot":"","sources":["../src/udt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,eAAe,CAAC;AAGzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUtD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,eAAe,EAAE,GAAG,CAAC,GAAG,CAAC;IACzB,4EAA4E;IAC5E,aAAa,EAAE,GAAG,CAAC,UAAU,CAAC;CAC/B;AAOD,iCAAiC;AACjC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,GAAG,CAAC,KAAK,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,GAAG,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,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,GAAG,IAAI,CAKlF;CACF;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,qBAAqB,EAAE,GAAG,CAAC,UAAU,EACrC,MAAM,EAAE,GAAG,CAAC,iBAAiB,GAC5B,GAAG,CAAC,UAAU,CAQhB;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,aAAa,GAAG,GAAG,CAAC,UAAU,CAGvF;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,aAAa,GAAG,GAAG,CAAC,UAAU,CAGvF;AAQD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,iBAAiB,GAAG,aAAa,CAKhF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,iBAAiB,GAAG,aAAa,CAK9E;AAED,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC;CACnB"}
|
package/dist/udt.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ccc, mol } from "@ckb-ccc/core";
|
|
2
2
|
import { isDaoDeposit } from "./dao.js";
|
|
3
3
|
import { CheckedUint128LE, CheckedUint32LE, CheckedUint64LE } from "./utils/codec.js";
|
|
4
|
-
import { transactionHeaders } from "./utils/transaction_header.js";
|
|
5
4
|
const ickbXudtTypeOccupiedSize = 69;
|
|
6
5
|
const udtDataSize = 16;
|
|
7
6
|
const AR_0 = 10000000000000000n; // Base scale for CKB
|
|
@@ -40,19 +39,16 @@ export const ICKB_DEPOSIT_CAP = ccc.fixedPointFrom(100000); // 100,000 iCKB
|
|
|
40
39
|
export class IckbUdt {
|
|
41
40
|
/** The iCKB xUDT type script. */
|
|
42
41
|
script;
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
/** Out point of the iCKB Logic code cell required by this token. */
|
|
46
|
-
logicCode;
|
|
42
|
+
/** The iCKB dep group, which also carries the xUDT and iCKB Logic code cells. */
|
|
43
|
+
cellDeps;
|
|
47
44
|
/** Logic script whose hash is embedded in this iCKB xUDT type script. */
|
|
48
45
|
logicScript;
|
|
49
46
|
/** The Nervos DAO script, to recognize the first-phase deposits a transaction re-mints. */
|
|
50
47
|
daoScript;
|
|
51
48
|
/** Creates an instance of IckbUdt from its code and script references. */
|
|
52
|
-
constructor({
|
|
49
|
+
constructor({ script, cellDeps, logicScript, daoScript, }) {
|
|
53
50
|
this.script = ccc.Script.from(script);
|
|
54
|
-
this.
|
|
55
|
-
this.logicCode = ccc.OutPoint.from(logicCode);
|
|
51
|
+
this.cellDeps = cellDeps.map((cellDep) => ccc.CellDep.from(cellDep));
|
|
56
52
|
this.logicScript = ccc.Script.from(logicScript);
|
|
57
53
|
this.daoScript = ccc.Script.from(daoScript);
|
|
58
54
|
}
|
|
@@ -85,89 +81,39 @@ export class IckbUdt {
|
|
|
85
81
|
ccc.bytesFrom(cell.outputData).length >= udtDataSize);
|
|
86
82
|
}
|
|
87
83
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* - iCKB Logic code cell (this.logicCode)
|
|
93
|
-
*
|
|
94
|
-
* @param txLike - The transaction to add cell deps to.
|
|
95
|
-
* @returns The transaction with cell deps added.
|
|
96
|
-
*/
|
|
97
|
-
addCellDeps(txLike) {
|
|
98
|
-
const tx = ccc.Transaction.from(txLike);
|
|
99
|
-
addCodeDep(tx, this.udtCode);
|
|
100
|
-
addCodeDep(tx, this.logicCode);
|
|
101
|
-
return tx;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* iCKB carried by the transaction's inputs: xUDT balances plus receipt value,
|
|
105
|
-
* minus the first-phase deposits it re-mints. Final withdrawal inputs carry none.
|
|
106
|
-
* The protocol cells are valued at their deposit headers, each read once.
|
|
84
|
+
* iCKB carried by the transaction's inputs: xUDT balances plus receipt value, minus the
|
|
85
|
+
* first-phase deposits it re-mints. Receipts and deposits take the value the state read
|
|
86
|
+
* gave them at their deposit headers; a protocol input missing from `protocolCells` is
|
|
87
|
+
* a builder bug and throws, since iCKB Logic would refuse whatever it was valued at.
|
|
107
88
|
*/
|
|
108
|
-
async inputBalance(tx, client) {
|
|
109
|
-
const
|
|
110
|
-
try {
|
|
111
|
-
return await input.getCell(client);
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
throw new Error(`Failed to load input cell ${input.previousOutput.toHex()}`, {
|
|
115
|
-
cause: error,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}));
|
|
119
|
-
const valued = cells.map((cell) => this.protocolValue(cell));
|
|
120
|
-
const headers = await transactionHeaders(client, valued.flatMap((value) => (value === undefined ? [] : [value.txHash])));
|
|
89
|
+
async inputBalance(tx, client, protocolCells) {
|
|
90
|
+
const values = new Map(protocolCells.map(({ cell, udtValue }) => [cell.outPoint.toHex(), udtValue]));
|
|
121
91
|
let balance = ccc.Zero;
|
|
122
|
-
for (const
|
|
123
|
-
const
|
|
92
|
+
for (const input of tx.inputs) {
|
|
93
|
+
const cell = await input.getCell(client);
|
|
124
94
|
if (this.isUdt(cell)) {
|
|
125
|
-
balance +=
|
|
95
|
+
balance += ccc.udtBalanceFrom(cell.outputData);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const sign = this.protocolSign(cell);
|
|
99
|
+
if (sign === 0n) {
|
|
100
|
+
continue;
|
|
126
101
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
balance += value.sign * ickbValue(value.amount, header) * value.quantity;
|
|
102
|
+
const value = values.get(cell.outPoint.toHex());
|
|
103
|
+
if (value === undefined) {
|
|
104
|
+
throw new Error(`iCKB input ${cell.outPoint.toHex()} has no value from the state read`);
|
|
131
105
|
}
|
|
106
|
+
balance += sign * value;
|
|
132
107
|
}
|
|
133
108
|
return balance;
|
|
134
109
|
}
|
|
135
|
-
/**
|
|
136
|
-
|
|
137
|
-
if (this.isUdt(cell) || cell.outPoint === undefined) {
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
110
|
+
/** 1 for a receipt, -1 for a first-phase iCKB deposit, 0 for any other cell. */
|
|
111
|
+
protocolSign(cell) {
|
|
140
112
|
const { type, lock } = cell.cellOutput;
|
|
141
113
|
if (type !== undefined && this.logicScript.eq(type)) {
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
receipt = decodeReceiptData(cell.outputData);
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
throw new Error(`Invalid iCKB receipt payload at ${cell.outPoint.toHex()}: ${cell.outputData}`, { cause: error });
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
txHash: cell.outPoint.txHash,
|
|
151
|
-
amount: receipt.depositAmount,
|
|
152
|
-
quantity: receipt.depositQuantity,
|
|
153
|
-
sign: 1n,
|
|
154
|
-
};
|
|
114
|
+
return 1n;
|
|
155
115
|
}
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
txHash: cell.outPoint.txHash,
|
|
159
|
-
amount: cell.capacityFree,
|
|
160
|
-
quantity: 1n,
|
|
161
|
-
sign: -1n,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
/** iCKB the transaction's outputs require. */
|
|
167
|
-
outputBalance(tx) {
|
|
168
|
-
return Array.from(tx.outputCells).reduce((required, cell) => {
|
|
169
|
-
return this.isUdt(cell) ? required + decodeUdtBalance(cell.outputData) : required;
|
|
170
|
-
}, ccc.Zero);
|
|
116
|
+
return this.logicScript.eq(lock) && isDaoDeposit(cell, this.daoScript) ? -1n : 0n;
|
|
171
117
|
}
|
|
172
118
|
/** Adds the iCKB change output when the surplus is positive; zero needs no output. */
|
|
173
119
|
addChange(tx, lock, balance) {
|
|
@@ -177,15 +123,6 @@ export class IckbUdt {
|
|
|
177
123
|
tx.addOutput({ lock, type: this.script }, CheckedUint128LE.encode(balance));
|
|
178
124
|
}
|
|
179
125
|
}
|
|
180
|
-
function decodeUdtBalance(data) {
|
|
181
|
-
return CheckedUint128LE.decode(ccc.bytesFrom(data).slice(0, udtDataSize));
|
|
182
|
-
}
|
|
183
|
-
function addCodeDep(tx, outPoint) {
|
|
184
|
-
if (tx.cellDeps.some((dep) => dep.depType === "code" && dep.outPoint.eq(outPoint))) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
tx.addCellDeps({ outPoint, depType: "code" });
|
|
188
|
-
}
|
|
189
126
|
/**
|
|
190
127
|
* Calculates iCKB value for unoccupied CKB capacity at a deposit header.
|
|
191
128
|
*
|
|
@@ -194,28 +131,27 @@ function addCodeDep(tx, outPoint) {
|
|
|
194
131
|
* excess amount.
|
|
195
132
|
*/
|
|
196
133
|
export function ickbValue(ckbUnoccupiedCapacity, header) {
|
|
197
|
-
let ickbAmount =
|
|
134
|
+
let ickbAmount = udtFromCkb(ckbUnoccupiedCapacity, ickbAccountingRatio(header));
|
|
198
135
|
if (ICKB_DEPOSIT_CAP < ickbAmount) {
|
|
199
136
|
// Apply a 10% discount for the amount exceeding the soft iCKB cap per deposit.
|
|
200
137
|
ickbAmount -= (ickbAmount - ICKB_DEPOSIT_CAP) / 10n;
|
|
201
138
|
}
|
|
202
139
|
return ickbAmount;
|
|
203
140
|
}
|
|
204
|
-
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
141
|
+
/** The iCKB worth `amount` CKB at `ratio`, rounded down. */
|
|
142
|
+
export function udtFromCkb(amount, ratio) {
|
|
143
|
+
assertPositive(ratio);
|
|
144
|
+
return (amount * ratio.ckbScale) / ratio.udtScale;
|
|
145
|
+
}
|
|
146
|
+
/** The CKB worth `amount` iCKB at `ratio`, rounded down. */
|
|
147
|
+
export function ckbFromUdt(amount, ratio) {
|
|
148
|
+
assertPositive(ratio);
|
|
149
|
+
return (amount * ratio.udtScale) / ratio.ckbScale;
|
|
150
|
+
}
|
|
151
|
+
function assertPositive({ ckbScale, udtScale }) {
|
|
152
|
+
if (ckbScale <= 0n || udtScale <= 0n) {
|
|
214
153
|
throw new Error("Exchange ratio scales must be positive");
|
|
215
154
|
}
|
|
216
|
-
return isCkb2Udt
|
|
217
|
-
? (amount * ratio.ckbScale) / ratio.udtScale
|
|
218
|
-
: (amount * ratio.udtScale) / ratio.ckbScale;
|
|
219
155
|
}
|
|
220
156
|
/**
|
|
221
157
|
* Calculates the free-capacity accounting ratio at a block header.
|
package/dist/udt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"udt.js","sourceRoot":"","sources":["../src/udt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"udt.js","sourceRoot":"","sources":["../src/udt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGtF,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,IAAI,GAAY,kBAAkB,CAAC,CA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AAC,EAAE,QAAQ,EAAE,QAAQ,EAAiB;IAC3D,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAA6B;IAC/D,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE;KACxB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA6B;IAC7D,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,oBAAoB;KAC/C,CAAC;AACJ,CAAC"}
|
package/dist/utils/chain.d.ts
CHANGED
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
import type { ccc } from "@ckb-ccc/core";
|
|
2
1
|
/** Public CKB networks supported by Stack consumers. */
|
|
3
2
|
export type SupportedChain = "mainnet" | "testnet";
|
|
4
|
-
/** Canonical public identity of one supported CKB network. */
|
|
5
|
-
export interface ChainIdentity {
|
|
6
|
-
/** Stack network selector represented by this identity. */
|
|
7
|
-
readonly chain: SupportedChain;
|
|
8
|
-
/** CKB specification network name. */
|
|
9
|
-
readonly networkName: string;
|
|
10
|
-
/** Canonical genesis block hash. */
|
|
11
|
-
readonly genesisHash: ccc.Hex;
|
|
12
|
-
/** Canonical genesis message used by the CKB specification. */
|
|
13
|
-
readonly genesisMessage: string;
|
|
14
|
-
/** Public specification location from which the genesis identity was derived. */
|
|
15
|
-
readonly genesisSource: string;
|
|
16
|
-
/** Canonical address prefix for this network. */
|
|
17
|
-
readonly addressPrefix: "ckb" | "ckt";
|
|
18
|
-
}
|
|
19
|
-
/** The immutable canonical identity of each supported chain. */
|
|
20
|
-
export declare const chainIdentities: Readonly<{
|
|
21
|
-
readonly mainnet: Readonly<{
|
|
22
|
-
chain: "mainnet";
|
|
23
|
-
networkName: "ckb";
|
|
24
|
-
genesisHash: "0x92b197aa1fba0f63633922c61c92375c9c074a93e85963554f5499fe1450d0e5";
|
|
25
|
-
genesisMessage: "lina 0x18e020f6b1237a3d06b75121f25a7efa0550e4b3f44f974822f471902424c104";
|
|
26
|
-
genesisSource: "https://raw.githubusercontent.com/nervosnetwork/ckb/develop/resource/specs/mainnet.toml";
|
|
27
|
-
addressPrefix: "ckb";
|
|
28
|
-
}>;
|
|
29
|
-
readonly testnet: Readonly<{
|
|
30
|
-
chain: "testnet";
|
|
31
|
-
networkName: "ckb_testnet";
|
|
32
|
-
genesisHash: "0x10639e0895502b5688a6be8cf69460d76541bfa4821629d86d62ba0aae3f9606";
|
|
33
|
-
genesisMessage: "aggron-v4";
|
|
34
|
-
genesisSource: "https://raw.githubusercontent.com/nervosnetwork/ckb/develop/resource/specs/testnet.toml";
|
|
35
|
-
addressPrefix: "ckt";
|
|
36
|
-
}>;
|
|
37
|
-
}>;
|
|
38
3
|
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/utils/chain.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/utils/chain.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC"}
|