@ickb/sdk 1000.0.82 → 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 +84 -32
- package/dist/constants.d.ts +9 -22
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +62 -76
- package/dist/constants.js.map +1 -1
- package/dist/conversion/estimate.d.ts +33 -0
- package/dist/conversion/estimate.d.ts.map +1 -0
- package/dist/conversion/estimate.js +117 -0
- package/dist/conversion/estimate.js.map +1 -0
- package/dist/conversion/maturity.d.ts +15 -0
- package/dist/conversion/maturity.d.ts.map +1 -0
- package/dist/conversion/maturity.js +113 -0
- package/dist/conversion/maturity.js.map +1 -0
- package/dist/conversion/plans.d.ts +20 -0
- package/dist/conversion/plans.d.ts.map +1 -0
- package/dist/conversion/plans.js +106 -0
- package/dist/conversion/plans.js.map +1 -0
- package/dist/conversion/projection.d.ts +21 -0
- package/dist/conversion/projection.d.ts.map +1 -0
- package/dist/conversion/projection.js +94 -0
- package/dist/conversion/projection.js.map +1 -0
- package/dist/conversion/types.d.ts +264 -0
- package/dist/conversion/types.d.ts.map +1 -0
- package/dist/conversion/types.js +2 -0
- package/dist/conversion/types.js.map +1 -0
- package/dist/conversion/withdrawal_ring.d.ts +34 -0
- package/dist/conversion/withdrawal_ring.d.ts.map +1 -0
- package/dist/conversion/withdrawal_ring.js +87 -0
- package/dist/conversion/withdrawal_ring.js.map +1 -0
- package/dist/dao.d.ts +100 -0
- package/dist/dao.d.ts.map +1 -0
- package/dist/dao.js +125 -0
- package/dist/dao.js.map +1 -0
- package/dist/index.d.ts +49 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/dist/logic.d.ts +81 -0
- package/dist/logic.d.ts.map +1 -0
- package/dist/logic.js +173 -0
- package/dist/logic.js.map +1 -0
- package/dist/order/cells.d.ts +168 -0
- package/dist/order/cells.d.ts.map +1 -0
- package/dist/order/cells.js +309 -0
- package/dist/order/cells.js.map +1 -0
- package/dist/order/conversion.d.ts +37 -0
- package/dist/order/conversion.d.ts.map +1 -0
- package/dist/order/conversion.js +120 -0
- package/dist/order/conversion.js.map +1 -0
- package/dist/order/fee.d.ts +9 -0
- package/dist/order/fee.d.ts.map +1 -0
- package/dist/order/fee.js +24 -0
- package/dist/order/fee.js.map +1 -0
- package/dist/order/fill.d.ts +36 -0
- package/dist/order/fill.d.ts.map +1 -0
- package/dist/order/fill.js +53 -0
- package/dist/order/fill.js.map +1 -0
- package/dist/order/info.d.ts +62 -0
- package/dist/order/info.d.ts.map +1 -0
- package/dist/order/info.js +102 -0
- package/dist/order/info.js.map +1 -0
- package/dist/order/master.d.ts +49 -0
- package/dist/order/master.d.ts.map +1 -0
- package/dist/order/master.js +27 -0
- package/dist/order/master.js.map +1 -0
- package/dist/order/matcher.d.ts +43 -0
- package/dist/order/matcher.d.ts.map +1 -0
- package/dist/order/matcher.js +124 -0
- package/dist/order/matcher.js.map +1 -0
- package/dist/order/order.d.ts +63 -0
- package/dist/order/order.d.ts.map +1 -0
- package/dist/order/order.js +234 -0
- package/dist/order/order.js.map +1 -0
- package/dist/order/order_data.d.ts +51 -0
- package/dist/order/order_data.d.ts.map +1 -0
- package/dist/order/order_data.js +67 -0
- package/dist/order/order_data.js.map +1 -0
- package/dist/order/ratio.d.ts +40 -0
- package/dist/order/ratio.d.ts.map +1 -0
- package/dist/order/ratio.js +74 -0
- package/dist/order/ratio.js.map +1 -0
- package/dist/order/relative.d.ts +43 -0
- package/dist/order/relative.d.ts.map +1 -0
- package/dist/order/relative.js +57 -0
- package/dist/order/relative.js.map +1 -0
- package/dist/owned_owner.d.ts +108 -0
- package/dist/owned_owner.d.ts.map +1 -0
- package/dist/owned_owner.js +260 -0
- package/dist/owned_owner.js.map +1 -0
- package/dist/sdk.d.ts +113 -41
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +410 -209
- package/dist/sdk.js.map +1 -1
- package/dist/send/sign_and_send_transaction.d.ts +61 -0
- package/dist/send/sign_and_send_transaction.d.ts.map +1 -0
- package/dist/send/sign_and_send_transaction.js +201 -0
- package/dist/send/sign_and_send_transaction.js.map +1 -0
- package/dist/send/wait_transaction.d.ts +42 -0
- package/dist/send/wait_transaction.d.ts.map +1 -0
- package/dist/send/wait_transaction.js +172 -0
- package/dist/send/wait_transaction.js.map +1 -0
- package/dist/udt.d.ts +108 -0
- package/dist/udt.d.ts.map +1 -0
- package/dist/udt.js +180 -0
- package/dist/udt.js.map +1 -0
- package/dist/utils/chain.d.ts +3 -0
- package/dist/utils/chain.d.ts.map +1 -0
- package/dist/utils/chain.js +2 -0
- package/dist/utils/chain.js.map +1 -0
- package/dist/utils/codec.d.ts +19 -0
- package/dist/utils/codec.d.ts.map +1 -0
- package/dist/utils/codec.js +69 -0
- package/dist/utils/codec.js.map +1 -0
- package/dist/utils/utils.d.ts +99 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +130 -0
- package/dist/utils/utils.js.map +1 -0
- 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 +19 -26
- package/src/constants.ts +65 -181
- package/src/conversion/estimate.ts +155 -0
- package/src/conversion/maturity.ts +158 -0
- package/src/conversion/plans.ts +144 -0
- package/src/conversion/projection.ts +136 -0
- package/src/conversion/types.ts +302 -0
- package/src/conversion/withdrawal_ring.ts +122 -0
- package/src/dao.ts +196 -0
- package/src/index.ts +89 -3
- package/src/logic.ts +283 -0
- package/src/order/cells.ts +383 -0
- package/src/order/conversion.ts +162 -0
- package/src/order/fee.ts +30 -0
- package/src/order/fill.ts +83 -0
- package/src/order/info.ts +181 -0
- package/src/order/master.ts +42 -0
- package/src/order/matcher.ts +191 -0
- package/src/order/order.ts +288 -0
- package/src/order/order_data.ts +131 -0
- package/src/order/ratio.ts +127 -0
- package/src/order/relative.ts +109 -0
- package/src/owned_owner.ts +364 -0
- package/src/sdk.ts +542 -440
- package/src/send/sign_and_send_transaction.ts +256 -0
- package/src/send/wait_transaction.ts +227 -0
- package/src/udt.ts +249 -0
- package/src/utils/chain.ts +2 -0
- package/src/utils/codec.ts +78 -0
- package/src/utils/utils.ts +208 -0
- package/src/utils/verified_client.ts +136 -0
- package/dist/codec.d.ts +0 -3
- package/dist/codec.d.ts.map +0 -1
- package/dist/codec.js +0 -58
- package/dist/codec.js.map +0 -1
- package/src/codec.ts +0 -138
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ccc, mol } from "@ckb-ccc/core";
|
|
2
|
+
import { CheckedUint64LE } from "../utils/codec.js";
|
|
3
|
+
import { compareBigInt } from "../utils/utils.js";
|
|
4
|
+
const maxUint64 = (1n << 64n) - 1n;
|
|
5
|
+
const RatioCodec = mol.struct({
|
|
6
|
+
ckbScale: CheckedUint64LE,
|
|
7
|
+
udtScale: CheckedUint64LE,
|
|
8
|
+
});
|
|
9
|
+
const RatioBase = ccc.Entity.Base();
|
|
10
|
+
// An interface, this class expression and a typed const rather than one plain class: a
|
|
11
|
+
// class extending `ccc.Entity.Base<...>()` emits an unexported `*_base` declaration, which
|
|
12
|
+
// API Extractor's ae-forgotten-export rejects (tried 2026-10-30).
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- Preserve the runtime constructor name.
|
|
14
|
+
const RatioImplementation = class Ratio extends RatioBase {
|
|
15
|
+
static {
|
|
16
|
+
ccc.codec(RatioCodec)(this);
|
|
17
|
+
}
|
|
18
|
+
/** CKB-side scale. */
|
|
19
|
+
ckbScale;
|
|
20
|
+
/** UDT-side scale. */
|
|
21
|
+
udtScale;
|
|
22
|
+
/** Creates a ratio from raw scales. */
|
|
23
|
+
constructor(ckbScale, udtScale) {
|
|
24
|
+
super();
|
|
25
|
+
this.ckbScale = ckbScale;
|
|
26
|
+
this.udtScale = udtScale;
|
|
27
|
+
}
|
|
28
|
+
/** Normalizes an exchange ratio wire object or existing entity into `Ratio`. */
|
|
29
|
+
static from(ratio) {
|
|
30
|
+
if (ratio instanceof Ratio) {
|
|
31
|
+
return ratio;
|
|
32
|
+
}
|
|
33
|
+
const { ckbScale, udtScale } = ratio;
|
|
34
|
+
return new Ratio(ckbScale, udtScale);
|
|
35
|
+
}
|
|
36
|
+
/** Throws when the ratio is neither empty nor fully populated. */
|
|
37
|
+
validate() {
|
|
38
|
+
if (this.ckbScale < 0n ||
|
|
39
|
+
this.ckbScale > maxUint64 ||
|
|
40
|
+
this.udtScale < 0n ||
|
|
41
|
+
this.udtScale > maxUint64) {
|
|
42
|
+
throw new Error("Ratio scale exceeds Uint64");
|
|
43
|
+
}
|
|
44
|
+
if (!this.isEmpty() && !this.isPopulated()) {
|
|
45
|
+
throw new Error("Ratio invalid: not empty, not populated");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Returns true for the sentinel empty ratio. */
|
|
49
|
+
isEmpty() {
|
|
50
|
+
return this.ckbScale === 0n && this.udtScale === 0n;
|
|
51
|
+
}
|
|
52
|
+
/** Returns true when both scales are positive. */
|
|
53
|
+
isPopulated() {
|
|
54
|
+
return this.ckbScale > 0n && this.udtScale > 0n;
|
|
55
|
+
}
|
|
56
|
+
/** Creates the sentinel empty ratio. */
|
|
57
|
+
static empty() {
|
|
58
|
+
return new Ratio(0n, 0n);
|
|
59
|
+
}
|
|
60
|
+
/** Compares two populated ratios by effective CKB-to-UDT price. */
|
|
61
|
+
compare(other) {
|
|
62
|
+
if (this.udtScale === other.udtScale) {
|
|
63
|
+
return compareBigInt(this.ckbScale, other.ckbScale);
|
|
64
|
+
}
|
|
65
|
+
if (this.ckbScale === other.ckbScale) {
|
|
66
|
+
return compareBigInt(other.udtScale, this.udtScale);
|
|
67
|
+
}
|
|
68
|
+
return compareBigInt(this.ckbScale * other.udtScale, other.ckbScale * this.udtScale);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/** CCC-backed ratio constructor and codec. */
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- The public type and runtime constructor intentionally share a name.
|
|
73
|
+
export const Ratio = RatioImplementation;
|
|
74
|
+
//# sourceMappingURL=ratio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ratio.js","sourceRoot":"","sources":["../../src/order/ratio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAsB,MAAM,mBAAmB,CAAC;AAEtE,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;AAEnC,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC;IAC5B,QAAQ,EAAE,eAAe;IACzB,QAAQ,EAAE,eAAe;CAC1B,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAwB,CAAC;AA8B1D,uFAAuF;AACvF,2FAA2F;AAC3F,kEAAkE;AAClE,kGAAkG;AAClG,MAAM,mBAAmB,GAAG,MAAM,KAAM,SAAQ,SAAS;IACvD;QACE,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,sBAAsB;IACN,QAAQ,CAAU;IAClC,sBAAsB;IACN,QAAQ,CAAU;IAElC,uCAAuC;IACvC,YAAY,QAAiB,EAAE,QAAiB;QAC9C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,gFAAgF;IACzE,MAAM,CAAU,IAAI,CAAC,KAAoB;QAC9C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM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C,QAAQ,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvF,CAAC;CACF,CAAC;AAEF,8CAA8C;AAC9C,kIAAkI;AAClI,MAAM,CAAC,MAAM,KAAK,GAQd,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
/**
|
|
3
|
+
* Wire shape for a relative master pointer.
|
|
4
|
+
*/
|
|
5
|
+
export interface RelativeLike {
|
|
6
|
+
/** Must be the 32-byte zero padding used by the standard encoding. */
|
|
7
|
+
padding: ccc.BytesLike;
|
|
8
|
+
/** Signed output-index distance from the current order to its master. */
|
|
9
|
+
distance: ccc.NumLike;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Relative pointer from an order output to its master output.
|
|
13
|
+
*/
|
|
14
|
+
export interface Relative {
|
|
15
|
+
/** Standard zero padding. */
|
|
16
|
+
padding: ccc.Bytes;
|
|
17
|
+
/** Signed output-index distance to the master output. */
|
|
18
|
+
distance: ccc.Num;
|
|
19
|
+
/** Creates a copy of this relative pointer. */
|
|
20
|
+
clone(): Relative;
|
|
21
|
+
/** Returns whether another value has the same padding and distance. */
|
|
22
|
+
eq(other: RelativeLike): boolean;
|
|
23
|
+
/** Returns the CKB hash of the serialized relative pointer. */
|
|
24
|
+
hash(): ccc.Hex;
|
|
25
|
+
/** Serializes the relative pointer to bytes. */
|
|
26
|
+
toBytes(): ccc.Bytes;
|
|
27
|
+
/** Serializes the relative pointer to full-width hexadecimal. */
|
|
28
|
+
toHex(): ccc.Hex;
|
|
29
|
+
/** Throws unless padding is canonical and distance fits Int32. */
|
|
30
|
+
validate(): void;
|
|
31
|
+
}
|
|
32
|
+
/** CCC-backed relative-pointer constructor and codec. */
|
|
33
|
+
export declare const Relative: {
|
|
34
|
+
byteLength?: number;
|
|
35
|
+
new (padding: ccc.Bytes, distance: ccc.Num): Relative;
|
|
36
|
+
create: (distance: ccc.Num) => Relative;
|
|
37
|
+
decode: (encoded: ccc.BytesLike) => Relative;
|
|
38
|
+
encode: (relative: RelativeLike) => ccc.Bytes;
|
|
39
|
+
from: (relative: RelativeLike) => Relative;
|
|
40
|
+
fromBytes: (encoded: ccc.BytesLike) => Relative;
|
|
41
|
+
padding: () => ccc.Bytes;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=relative.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relative.d.ts","sourceRoot":"","sources":["../../src/order/relative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,eAAe,CAAC;AAMzC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC;IACvB,yEAAyE;IACzE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB;AASD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,6BAA6B;IAC7B,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC;IACnB,yDAAyD;IACzD,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC;IAClB,+CAA+C;IAC/C,KAAK,IAAI,QAAQ,CAAC;IAClB,uEAAuE;IACvE,EAAE,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;IACjC,+DAA+D;IAC/D,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC;IAChB,gDAAgD;IAChD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC;IACrB,iEAAiE;IACjE,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC;IACjB,kEAAkE;IAClE,QAAQ,IAAI,IAAI,CAAC;CAClB;AAsDD,yDAAyD;AAEzD,eAAO,MAAM,QAAQ,EAAE;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC;IACtD,MAAM,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,KAAK,QAAQ,CAAC;IACxC,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,KAAK,QAAQ,CAAC;IAC7C,MAAM,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,GAAG,CAAC,KAAK,CAAC;IAC9C,IAAI,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,QAAQ,CAAC;IAC3C,SAAS,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,KAAK,QAAQ,CAAC;IAChD,OAAO,EAAE,MAAM,GAAG,CAAC,KAAK,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ccc, mol } from "@ckb-ccc/core";
|
|
2
|
+
import { CheckedInt32LE } from "../utils/codec.js";
|
|
3
|
+
const minInt32 = -(1n << 31n);
|
|
4
|
+
const maxInt32 = (1n << 31n) - 1n;
|
|
5
|
+
const RelativeCodec = mol.struct({
|
|
6
|
+
padding: mol.Byte32,
|
|
7
|
+
distance: CheckedInt32LE,
|
|
8
|
+
});
|
|
9
|
+
const RelativeBase = ccc.Entity.Base();
|
|
10
|
+
// An interface, this class expression and a typed const rather than one plain class: a
|
|
11
|
+
// class extending `ccc.Entity.Base<...>()` emits an unexported `*_base` declaration, which
|
|
12
|
+
// API Extractor's ae-forgotten-export rejects (tried 2026-10-30).
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- Preserve the runtime constructor name.
|
|
14
|
+
const RelativeImplementation = class Relative extends RelativeBase {
|
|
15
|
+
static {
|
|
16
|
+
ccc.codec(RelativeCodec)(this);
|
|
17
|
+
}
|
|
18
|
+
/** Standard zero padding. */
|
|
19
|
+
padding;
|
|
20
|
+
/** Signed output-index distance to the master output. */
|
|
21
|
+
distance;
|
|
22
|
+
/** Creates a normalized relative pointer. */
|
|
23
|
+
constructor(padding, distance) {
|
|
24
|
+
super();
|
|
25
|
+
this.padding = padding;
|
|
26
|
+
this.distance = distance;
|
|
27
|
+
}
|
|
28
|
+
/** Normalizes a relative pointer wire object or existing entity into `Relative`. */
|
|
29
|
+
static from(relative) {
|
|
30
|
+
if (relative instanceof Relative) {
|
|
31
|
+
return relative;
|
|
32
|
+
}
|
|
33
|
+
const { padding, distance } = relative;
|
|
34
|
+
return new Relative(ccc.bytesFrom(padding), ccc.numFrom(distance));
|
|
35
|
+
}
|
|
36
|
+
/** Creates a relative pointer with standard zero padding. */
|
|
37
|
+
static create(distance) {
|
|
38
|
+
return new Relative(Relative.padding(), distance);
|
|
39
|
+
}
|
|
40
|
+
/** Returns the standard 32-byte zero padding. */
|
|
41
|
+
static padding() {
|
|
42
|
+
return new Uint8Array(32);
|
|
43
|
+
}
|
|
44
|
+
/** Throws when padding is not the standard 32-byte zero value. */
|
|
45
|
+
validate() {
|
|
46
|
+
if (this.padding.length !== 32 || this.padding.some((x) => x !== 0)) {
|
|
47
|
+
throw new Error("Relative master invalid, non standard padding");
|
|
48
|
+
}
|
|
49
|
+
if (this.distance < minInt32 || this.distance > maxInt32) {
|
|
50
|
+
throw new Error("Relative master distance exceeds Int32");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/** CCC-backed relative-pointer constructor and codec. */
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- The public type and runtime constructor intentionally share a name.
|
|
56
|
+
export const Relative = RelativeImplementation;
|
|
57
|
+
//# sourceMappingURL=relative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relative.js","sourceRoot":"","sources":["../../src/order/relative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAA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QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,iDAAiD;IAC1C,MAAM,CAAC,OAAO;QACnB,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,kEAAkE;IAC3D,QAAQ;QACb,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,IAAI,CAAC,QAAQ,GAAG,QAAQ,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;CACF,CAAC;AAEF,yDAAyD;AACzD,kIAAkI;AAClI,MAAM,CAAC,MAAM,QAAQ,GASjB,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import type { IckbDepositCell } from "./logic.js";
|
|
3
|
+
import { type ScannedCell, type ScriptDeps, type ValueComponents } from "./utils/utils.js";
|
|
4
|
+
/**
|
|
5
|
+
* A live Nervos DAO withdrawal request cell, valued at the two headers it spans.
|
|
6
|
+
*/
|
|
7
|
+
export interface DaoWithdrawalRequestCell {
|
|
8
|
+
/** The DAO withdrawal request cell. */
|
|
9
|
+
cell: ccc.Cell;
|
|
10
|
+
/** The deposit header and the request's own header. */
|
|
11
|
+
headers: [ccc.ClientBlockHeader, ccc.ClientBlockHeader];
|
|
12
|
+
/** The DAO claim epoch of the request. */
|
|
13
|
+
maturity: ccc.Epoch;
|
|
14
|
+
/** Whether the claim epoch is at or before the tip: the request can be withdrawn. */
|
|
15
|
+
isReady: boolean;
|
|
16
|
+
/** The capacity the withdrawal returns: the cell's plus the interest. */
|
|
17
|
+
ckbValue: ccc.FixedPoint;
|
|
18
|
+
}
|
|
19
|
+
/** The owner marker payload: where its owned cell sits in their shared transaction. */
|
|
20
|
+
export interface OwnerData {
|
|
21
|
+
/** Signed output-index distance from the owner marker to the owned cell. */
|
|
22
|
+
ownedDistance: ccc.Num;
|
|
23
|
+
}
|
|
24
|
+
/** Encodes an owner marker payload. */
|
|
25
|
+
export declare function encodeOwnerData(data: OwnerData): ccc.Bytes;
|
|
26
|
+
/**
|
|
27
|
+
* Decodes the fixed owner-data prefix and ignores trailing cell payload bytes.
|
|
28
|
+
*
|
|
29
|
+
* @remarks The owner data prefix is 4 bytes after the `0x` marker: a signed little-endian
|
|
30
|
+
* relative output-index distance to the owned cell. Later bytes belong to other protocol
|
|
31
|
+
* data and are intentionally tolerated here.
|
|
32
|
+
*/
|
|
33
|
+
export declare function decodeOwnerData(outputData: ccc.Hex): OwnerData;
|
|
34
|
+
/**
|
|
35
|
+
* Wraps an owner marker cell that references an owned withdrawal request.
|
|
36
|
+
*/
|
|
37
|
+
export declare class OwnerCell {
|
|
38
|
+
/** The live owner marker cell whose output data points to the owned request. */
|
|
39
|
+
cell: ccc.Cell;
|
|
40
|
+
/** Creates an owner marker wrapper for a live cell. */
|
|
41
|
+
constructor(cell: ccc.Cell);
|
|
42
|
+
/**
|
|
43
|
+
* Returns the owned withdrawal request out point referenced by this owner marker.
|
|
44
|
+
*
|
|
45
|
+
* @remarks Owner data stores a signed output-index distance. The owned cell is resolved
|
|
46
|
+
* on the same transaction hash as the owner marker cell.
|
|
47
|
+
*/
|
|
48
|
+
getOwned(): ccc.OutPoint;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Pairs an owned DAO withdrawal request with the owner marker cell that points to it.
|
|
52
|
+
*/
|
|
53
|
+
export declare class WithdrawalGroup implements ValueComponents {
|
|
54
|
+
/** The decoded DAO withdrawal request controlled by this owner marker. */
|
|
55
|
+
owned: DaoWithdrawalRequestCell;
|
|
56
|
+
/** The owner marker cell that references the owned withdrawal request. */
|
|
57
|
+
owner: OwnerCell;
|
|
58
|
+
/** Creates a withdrawal group from a decoded request and its owner marker. */
|
|
59
|
+
constructor(owned: DaoWithdrawalRequestCell, owner: OwnerCell);
|
|
60
|
+
/** Returns the total CKB capacity in the owned withdrawal and owner marker cells. */
|
|
61
|
+
get ckbValue(): ccc.FixedPoint;
|
|
62
|
+
/** Returns the iCKB amount represented by the owned withdrawal request. */
|
|
63
|
+
get udtValue(): ccc.FixedPoint;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Builds and finds Owned Owner withdrawal groups for an iCKB deployment.
|
|
67
|
+
*/
|
|
68
|
+
export declare class OwnedOwnerManager implements ScriptDeps {
|
|
69
|
+
/** The Owned Owner script used as owner marker type and withdrawal request lock. */
|
|
70
|
+
readonly script: ccc.Script;
|
|
71
|
+
/** Cell dependencies required to execute the Owned Owner script. */
|
|
72
|
+
readonly cellDeps: ccc.CellDep[];
|
|
73
|
+
/** The Nervos DAO script the withdrawal requests carry, with its cell deps. */
|
|
74
|
+
readonly dao: ScriptDeps;
|
|
75
|
+
/** Creates the manager for one Owned Owner deployment over one DAO deployment. */
|
|
76
|
+
constructor(script: ccc.Script, cellDeps: ccc.CellDep[], dao: ScriptDeps);
|
|
77
|
+
/** Whether the cell is an owner marker for this manager's script. */
|
|
78
|
+
isOwner(cell: ccc.Cell): boolean;
|
|
79
|
+
/** Whether the cell is a DAO withdrawal request locked by this manager's script. */
|
|
80
|
+
isOwned(cell: ccc.Cell): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Spends the deposits into DAO withdrawal requests locked by the Owned Owner script,
|
|
83
|
+
* each followed by an owner marker locked by `lock` that points back at it.
|
|
84
|
+
*
|
|
85
|
+
* @remarks Completion (`IckbSdk.completeTransaction`) adds the dep group that also
|
|
86
|
+
* resolves the xUDT script.
|
|
87
|
+
*/
|
|
88
|
+
requestWithdrawal(txLike: ccc.TransactionLike, deposits: IckbDepositCell[], lock: ccc.Script): ccc.Transaction;
|
|
89
|
+
/**
|
|
90
|
+
* Spends the owned withdrawal requests and their owner markers, with the DAO header deps,
|
|
91
|
+
* since, and witness each request needs.
|
|
92
|
+
*
|
|
93
|
+
* @remarks The distinct deposit headers are moved to the front of the header deps and
|
|
94
|
+
* the withdrawal headers appended, so a deposit header's index is its rank among the
|
|
95
|
+
* collected withdrawals. Caller must ensure UDT cellDeps are added to the transaction.
|
|
96
|
+
*/
|
|
97
|
+
withdraw(txLike: ccc.TransactionLike, withdrawalGroups: WithdrawalGroup[]): ccc.Transaction;
|
|
98
|
+
/**
|
|
99
|
+
* The owner markers among `cells` paired with their owned withdrawal requests, which live
|
|
100
|
+
* in the marker's own transaction at the encoded distance, so the marker's block is the
|
|
101
|
+
* request's. Markers whose target is not an owned withdrawal request are skipped. Each
|
|
102
|
+
* header is read once per batch.
|
|
103
|
+
*/
|
|
104
|
+
withdrawalGroupsFrom(client: ccc.Client, cells: readonly ScannedCell[], tip: ccc.ClientBlockHeader): Promise<WithdrawalGroup[]>;
|
|
105
|
+
}
|
|
106
|
+
/** Values a DAO withdrawal request at its two headers and judges it claimable at the tip. */
|
|
107
|
+
export declare function withdrawalRequestCell(cell: ccc.Cell, depositHeader: ccc.ClientBlockHeader, requestHeader: ccc.ClientBlockHeader, tip: ccc.ClientBlockHeader): DaoWithdrawalRequestCell;
|
|
108
|
+
//# sourceMappingURL=owned_owner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owned_owner.d.ts","sourceRoot":"","sources":["../src/owned_owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,eAAe,CAAC;AAQzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,wBAAwB;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core";
|
|
2
|
+
import { assertDaoOutputLimit, DAO_HEADER_INDEX_LIMIT, DaoHeaderIndexError, isDaoWithdrawalRequest, pushHeaderDep, } from "./dao.js";
|
|
3
|
+
import { ickbValue } from "./udt.js";
|
|
4
|
+
import { CheckedInt32LE, CheckedUint64LE } from "./utils/codec.js";
|
|
5
|
+
import { headersByNumber, } from "./utils/utils.js";
|
|
6
|
+
const OwnerDataCodec = mol.struct({
|
|
7
|
+
ownedDistance: CheckedInt32LE,
|
|
8
|
+
});
|
|
9
|
+
// An owner marker's fixed prefix: a signed 32-bit distance.
|
|
10
|
+
const ownerDataBytes = 4;
|
|
11
|
+
/** Encodes an owner marker payload. */
|
|
12
|
+
export function encodeOwnerData(data) {
|
|
13
|
+
return OwnerDataCodec.encode(data);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Decodes the fixed owner-data prefix and ignores trailing cell payload bytes.
|
|
17
|
+
*
|
|
18
|
+
* @remarks The owner data prefix is 4 bytes after the `0x` marker: a signed little-endian
|
|
19
|
+
* relative output-index distance to the owned cell. Later bytes belong to other protocol
|
|
20
|
+
* data and are intentionally tolerated here.
|
|
21
|
+
*/
|
|
22
|
+
export function decodeOwnerData(outputData) {
|
|
23
|
+
const { ownedDistance } = OwnerDataCodec.decode(outputData.slice(0, 2 + 2 * ownerDataBytes));
|
|
24
|
+
return { ownedDistance: ccc.numFrom(ownedDistance) };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Wraps an owner marker cell that references an owned withdrawal request.
|
|
28
|
+
*/
|
|
29
|
+
export class OwnerCell {
|
|
30
|
+
/** The live owner marker cell whose output data points to the owned request. */
|
|
31
|
+
cell;
|
|
32
|
+
/** Creates an owner marker wrapper for a live cell. */
|
|
33
|
+
constructor(cell) {
|
|
34
|
+
this.cell = cell;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the owned withdrawal request out point referenced by this owner marker.
|
|
38
|
+
*
|
|
39
|
+
* @remarks Owner data stores a signed output-index distance. The owned cell is resolved
|
|
40
|
+
* on the same transaction hash as the owner marker cell.
|
|
41
|
+
*/
|
|
42
|
+
getOwned() {
|
|
43
|
+
const { txHash, index } = this.cell.outPoint;
|
|
44
|
+
let ownedDistance;
|
|
45
|
+
try {
|
|
46
|
+
({ ownedDistance } = decodeOwnerData(this.cell.outputData));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new Error(`Invalid owner marker payload at ${this.cell.outPoint.toHex()}: ${this.cell.outputData}`, { cause: error });
|
|
50
|
+
}
|
|
51
|
+
const ownedIndex = index + ownedDistance;
|
|
52
|
+
if (ownedIndex < 0n) {
|
|
53
|
+
throw new Error(`Owner marker ${this.cell.outPoint.toHex()} points before output 0 with distance ${String(ownedDistance)}`);
|
|
54
|
+
}
|
|
55
|
+
return new ccc.OutPoint(txHash, ownedIndex);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pairs an owned DAO withdrawal request with the owner marker cell that points to it.
|
|
60
|
+
*/
|
|
61
|
+
export class WithdrawalGroup {
|
|
62
|
+
/** The decoded DAO withdrawal request controlled by this owner marker. */
|
|
63
|
+
owned;
|
|
64
|
+
/** The owner marker cell that references the owned withdrawal request. */
|
|
65
|
+
owner;
|
|
66
|
+
/** Creates a withdrawal group from a decoded request and its owner marker. */
|
|
67
|
+
constructor(owned, owner) {
|
|
68
|
+
this.owned = owned;
|
|
69
|
+
this.owner = owner;
|
|
70
|
+
}
|
|
71
|
+
/** Returns the total CKB capacity in the owned withdrawal and owner marker cells. */
|
|
72
|
+
get ckbValue() {
|
|
73
|
+
return this.owned.ckbValue + this.owner.cell.cellOutput.capacity;
|
|
74
|
+
}
|
|
75
|
+
/** Returns the iCKB amount represented by the owned withdrawal request. */
|
|
76
|
+
get udtValue() {
|
|
77
|
+
return ickbValue(this.owned.cell.capacityFree, this.owned.headers[0]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Builds and finds Owned Owner withdrawal groups for an iCKB deployment.
|
|
82
|
+
*/
|
|
83
|
+
export class OwnedOwnerManager {
|
|
84
|
+
/** The Owned Owner script used as owner marker type and withdrawal request lock. */
|
|
85
|
+
script;
|
|
86
|
+
/** Cell dependencies required to execute the Owned Owner script. */
|
|
87
|
+
cellDeps;
|
|
88
|
+
/** The Nervos DAO script the withdrawal requests carry, with its cell deps. */
|
|
89
|
+
dao;
|
|
90
|
+
/** Creates the manager for one Owned Owner deployment over one DAO deployment. */
|
|
91
|
+
constructor(script, cellDeps, dao) {
|
|
92
|
+
this.script = script;
|
|
93
|
+
this.cellDeps = cellDeps;
|
|
94
|
+
this.dao = dao;
|
|
95
|
+
}
|
|
96
|
+
/** Whether the cell is an owner marker for this manager's script. */
|
|
97
|
+
isOwner(cell) {
|
|
98
|
+
if (cell.cellOutput.type?.eq(this.script) !== true || cell.outputData.length < 10) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
new OwnerCell(cell).getOwned();
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Whether the cell is a DAO withdrawal request locked by this manager's script. */
|
|
110
|
+
isOwned(cell) {
|
|
111
|
+
return (isDaoWithdrawalRequest(cell, this.dao.script) &&
|
|
112
|
+
cell.cellOutput.lock.eq(this.script));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Spends the deposits into DAO withdrawal requests locked by the Owned Owner script,
|
|
116
|
+
* each followed by an owner marker locked by `lock` that points back at it.
|
|
117
|
+
*
|
|
118
|
+
* @remarks Completion (`IckbSdk.completeTransaction`) adds the dep group that also
|
|
119
|
+
* resolves the xUDT script.
|
|
120
|
+
*/
|
|
121
|
+
requestWithdrawal(txLike, deposits, lock) {
|
|
122
|
+
const tx = ccc.Transaction.from(txLike);
|
|
123
|
+
if (deposits.length === 0) {
|
|
124
|
+
return tx;
|
|
125
|
+
}
|
|
126
|
+
// The DAO script pairs each request output with the input at the same index.
|
|
127
|
+
if (tx.inputs.length !== tx.outputs.length ||
|
|
128
|
+
tx.outputs.length !== tx.outputsData.length) {
|
|
129
|
+
throw new Error("Transaction has different inputs and outputs lengths");
|
|
130
|
+
}
|
|
131
|
+
tx.addCellDeps(this.cellDeps);
|
|
132
|
+
tx.addCellDeps(this.dao.cellDeps);
|
|
133
|
+
const requestStart = tx.outputs.length;
|
|
134
|
+
for (const { cell, header } of deposits) {
|
|
135
|
+
if (cell.cellOutput.lock.args.length !== this.script.args.length) {
|
|
136
|
+
throw new Error("Withdrawal request lock args has different size from deposit");
|
|
137
|
+
}
|
|
138
|
+
pushHeaderDep(tx, header.hash);
|
|
139
|
+
tx.addInput(cell);
|
|
140
|
+
tx.addOutput({ capacity: cell.cellOutput.capacity, lock: this.script, type: this.dao.script }, CheckedUint64LE.encode(header.number));
|
|
141
|
+
}
|
|
142
|
+
for (let index = 0; index < deposits.length; index += 1) {
|
|
143
|
+
tx.addOutput({ lock, type: this.script },
|
|
144
|
+
// Negative: owner markers are appended after their withdrawal outputs.
|
|
145
|
+
encodeOwnerData({
|
|
146
|
+
ownedDistance: BigInt(requestStart + index - tx.outputs.length),
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
assertDaoOutputLimit(tx, this.dao.script);
|
|
150
|
+
return tx;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Spends the owned withdrawal requests and their owner markers, with the DAO header deps,
|
|
154
|
+
* since, and witness each request needs.
|
|
155
|
+
*
|
|
156
|
+
* @remarks The distinct deposit headers are moved to the front of the header deps and
|
|
157
|
+
* the withdrawal headers appended, so a deposit header's index is its rank among the
|
|
158
|
+
* collected withdrawals. Caller must ensure UDT cellDeps are added to the transaction.
|
|
159
|
+
*/
|
|
160
|
+
withdraw(txLike, withdrawalGroups) {
|
|
161
|
+
const tx = ccc.Transaction.from(txLike);
|
|
162
|
+
if (withdrawalGroups.length === 0) {
|
|
163
|
+
return tx;
|
|
164
|
+
}
|
|
165
|
+
for (const group of withdrawalGroups) {
|
|
166
|
+
const ownedOutPoint = group.owned.cell.outPoint;
|
|
167
|
+
const linkedOutPoint = group.owner.getOwned();
|
|
168
|
+
if (!linkedOutPoint.eq(ownedOutPoint)) {
|
|
169
|
+
throw new Error(`Withdrawal owner ${group.owner.cell.outPoint.toHex()} points to ${linkedOutPoint.toHex()} but group owned cell is ${ownedOutPoint.toHex()}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
tx.addCellDeps(this.cellDeps);
|
|
173
|
+
tx.addCellDeps(this.dao.cellDeps);
|
|
174
|
+
// Only this step names a header by index, and the deployed script reads that index as
|
|
175
|
+
// one byte, so the deposit headers go first, ahead of whatever the requests and receipts
|
|
176
|
+
// pushed: the limit then counts these alone. Safe because nothing else in the stack reads
|
|
177
|
+
// a header by position and every built transaction passes here once.
|
|
178
|
+
const depositHashes = [
|
|
179
|
+
...new Set(withdrawalGroups.map(({ owned }) => owned.headers[0].hash)),
|
|
180
|
+
];
|
|
181
|
+
tx.headerDeps = [
|
|
182
|
+
...depositHashes,
|
|
183
|
+
...tx.headerDeps.filter((hash) => !depositHashes.includes(hash)),
|
|
184
|
+
];
|
|
185
|
+
for (const { owned } of withdrawalGroups) {
|
|
186
|
+
pushHeaderDep(tx, owned.headers[1].hash);
|
|
187
|
+
}
|
|
188
|
+
for (const { owned } of withdrawalGroups) {
|
|
189
|
+
const headerIndex = tx.headerDeps.indexOf(owned.headers[0].hash);
|
|
190
|
+
// The deployed dao.c reads one byte of the u64 index field (RFC 0023 erratum,
|
|
191
|
+
// nervosnetwork/rfcs pull 456), so index 256 would be read as 0.
|
|
192
|
+
if (headerIndex >= DAO_HEADER_INDEX_LIMIT) {
|
|
193
|
+
throw new DaoHeaderIndexError(headerIndex);
|
|
194
|
+
}
|
|
195
|
+
const inputIndex = tx.addInput({
|
|
196
|
+
outPoint: owned.cell.outPoint,
|
|
197
|
+
cellOutput: owned.cell.cellOutput,
|
|
198
|
+
outputData: owned.cell.outputData,
|
|
199
|
+
since: { relative: "absolute", metric: "epoch", value: owned.maturity.toNum() },
|
|
200
|
+
}) - 1;
|
|
201
|
+
const witness = tx.getWitnessArgs(inputIndex) ?? ccc.WitnessArgs.from({});
|
|
202
|
+
if ((witness.inputType ?? "") !== "") {
|
|
203
|
+
throw new Error("Witnesses of withdrawal request already in use");
|
|
204
|
+
}
|
|
205
|
+
witness.inputType = ccc.hexFrom(CheckedUint64LE.encode(headerIndex));
|
|
206
|
+
tx.setWitnessArgs(inputIndex, witness);
|
|
207
|
+
}
|
|
208
|
+
for (const { owner } of withdrawalGroups) {
|
|
209
|
+
tx.addInput(owner.cell);
|
|
210
|
+
}
|
|
211
|
+
assertDaoOutputLimit(tx, this.dao.script);
|
|
212
|
+
return tx;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The owner markers among `cells` paired with their owned withdrawal requests, which live
|
|
216
|
+
* in the marker's own transaction at the encoded distance, so the marker's block is the
|
|
217
|
+
* request's. Markers whose target is not an owned withdrawal request are skipped. Each
|
|
218
|
+
* header is read once per batch.
|
|
219
|
+
*/
|
|
220
|
+
async withdrawalGroupsFrom(client, cells, tip) {
|
|
221
|
+
const owners = cells
|
|
222
|
+
.filter(({ cell }) => this.isOwner(cell))
|
|
223
|
+
.map(({ cell, blockNumber }) => ({ owner: new OwnerCell(cell), blockNumber }));
|
|
224
|
+
const ownedCells = await Promise.all(owners.map(async ({ owner }) => client.getCell(owner.getOwned())));
|
|
225
|
+
const pairs = owners.flatMap(({ owner, blockNumber }, index) => {
|
|
226
|
+
const owned = ownedCells[index];
|
|
227
|
+
return owned !== undefined && this.isOwned(owned)
|
|
228
|
+
? [{ owner, owned, blockNumber, depositBlockNumber: depositBlockNumberOf(owned) }]
|
|
229
|
+
: [];
|
|
230
|
+
});
|
|
231
|
+
const headers = await headersByNumber(client, pairs.flatMap((pair) => [pair.depositBlockNumber, pair.blockNumber]));
|
|
232
|
+
return pairs.map(({ owner, owned, blockNumber, depositBlockNumber }) => new WithdrawalGroup(withdrawalRequestCell(owned,
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- both headers were read above.
|
|
234
|
+
headers.get(depositBlockNumber),
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- both headers were read above.
|
|
236
|
+
headers.get(blockNumber), tip), owner));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/** Values a DAO withdrawal request at its two headers and judges it claimable at the tip. */
|
|
240
|
+
export function withdrawalRequestCell(cell, depositHeader, requestHeader, tip) {
|
|
241
|
+
const interests = ccc.calcDaoProfit(cell.capacityFree, depositHeader, requestHeader);
|
|
242
|
+
const maturity = ccc.calcDaoClaimEpoch(depositHeader, requestHeader);
|
|
243
|
+
return {
|
|
244
|
+
cell,
|
|
245
|
+
headers: [depositHeader, requestHeader],
|
|
246
|
+
maturity,
|
|
247
|
+
isReady: maturity.compare(tip.epoch) <= 0,
|
|
248
|
+
ckbValue: cell.cellOutput.capacity + interests,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/** The deposit block number a withdrawal request records in its data. */
|
|
252
|
+
function depositBlockNumberOf(cell) {
|
|
253
|
+
try {
|
|
254
|
+
return CheckedUint64LE.decode(cell.outputData);
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
throw new Error(`Invalid DAO withdrawal request payload at ${cell.outPoint.toHex()}: ${cell.outputData}`, { cause: error });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=owned_owner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owned_owner.js","sourceRoot":"","sources":["../src/owned_owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,sB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