@mysten-incubation/hashi 0.0.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 +1 -0
- package/dist/bitcoin.d.mts +140 -0
- package/dist/bitcoin.mjs +272 -0
- package/dist/client.d.mts +318 -0
- package/dist/client.mjs +522 -0
- package/dist/constants.mjs +60 -0
- package/dist/contracts/hashi/bitcoin_state.mjs +28 -0
- package/dist/contracts/hashi/committee.mjs +40 -0
- package/dist/contracts/hashi/committee_set.mjs +34 -0
- package/dist/contracts/hashi/config.mjs +28 -0
- package/dist/contracts/hashi/config_value.mjs +21 -0
- package/dist/contracts/hashi/deposit.mjs +67 -0
- package/dist/contracts/hashi/deposit_queue.mjs +33 -0
- package/dist/contracts/hashi/deps/sui/bag.mjs +42 -0
- package/dist/contracts/hashi/deps/sui/balance.mjs +20 -0
- package/dist/contracts/hashi/deps/sui/group_ops.mjs +16 -0
- package/dist/contracts/hashi/deps/sui/object_bag.mjs +25 -0
- package/dist/contracts/hashi/deps/sui/package.mjs +26 -0
- package/dist/contracts/hashi/deps/sui/table.mjs +37 -0
- package/dist/contracts/hashi/deps/sui/vec_map.mjs +36 -0
- package/dist/contracts/hashi/deps/sui/vec_set.mjs +25 -0
- package/dist/contracts/hashi/hashi.mjs +29 -0
- package/dist/contracts/hashi/proposals.mjs +18 -0
- package/dist/contracts/hashi/treasury.mjs +28 -0
- package/dist/contracts/hashi/utxo.mjs +56 -0
- package/dist/contracts/hashi/utxo_pool.mjs +35 -0
- package/dist/contracts/hashi/withdraw.mjs +91 -0
- package/dist/contracts/hashi/withdrawal_queue.mjs +131 -0
- package/dist/contracts/utils/index.d.mts +8 -0
- package/dist/contracts/utils/index.mjs +118 -0
- package/dist/errors.d.mts +118 -0
- package/dist/errors.mjs +118 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +5 -0
- package/dist/types.d.mts +137 -0
- package/dist/util.mjs +50 -0
- package/package.json +64 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
+
import { VecMap } from "./deps/sui/vec_map.mjs";
|
|
3
|
+
import { Value } from "./config_value.mjs";
|
|
4
|
+
import { VecSet } from "./deps/sui/vec_set.mjs";
|
|
5
|
+
import { UpgradeCap } from "./deps/sui/package.mjs";
|
|
6
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
7
|
+
|
|
8
|
+
//#region src/contracts/hashi/config.ts
|
|
9
|
+
/**************************************************************
|
|
10
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
11
|
+
**************************************************************/
|
|
12
|
+
/**
|
|
13
|
+
* Core configuration: versioning, pause state, upgrade management, and generic
|
|
14
|
+
* key-value config store. Chain-specific configuration (e.g. BTC fee parameters)
|
|
15
|
+
* lives in separate modules that use get/upsert.
|
|
16
|
+
*/
|
|
17
|
+
const $moduleName = "@local-pkg/hashi::config";
|
|
18
|
+
const Config = new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::Config`,
|
|
20
|
+
fields: {
|
|
21
|
+
config: VecMap(bcs.string(), Value),
|
|
22
|
+
enabled_versions: VecSet(bcs.u64()),
|
|
23
|
+
upgrade_cap: bcs.option(UpgradeCap)
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Config };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MoveEnum } from "../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/config_value.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
const $moduleName = "@local-pkg/hashi::config_value";
|
|
9
|
+
const Value = new MoveEnum({
|
|
10
|
+
name: `${$moduleName}::Value`,
|
|
11
|
+
fields: {
|
|
12
|
+
U64: bcs.u64(),
|
|
13
|
+
Address: bcs.Address,
|
|
14
|
+
String: bcs.string(),
|
|
15
|
+
Bool: bcs.bool(),
|
|
16
|
+
Bytes: bcs.vector(bcs.u8())
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Value };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
|
|
2
|
+
import { Utxo, UtxoId } from "./utxo.mjs";
|
|
3
|
+
import { CommitteeSignature } from "./committee.mjs";
|
|
4
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
5
|
+
|
|
6
|
+
//#region src/contracts/hashi/deposit.ts
|
|
7
|
+
/**************************************************************
|
|
8
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
9
|
+
**************************************************************/
|
|
10
|
+
const $moduleName = "@local-pkg/hashi::deposit";
|
|
11
|
+
const DepositConfirmationMessage = new MoveStruct({
|
|
12
|
+
name: `${$moduleName}::DepositConfirmationMessage`,
|
|
13
|
+
fields: {
|
|
14
|
+
request_id: bcs.Address,
|
|
15
|
+
utxo: Utxo
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const DepositRequestedEvent = new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::DepositRequestedEvent`,
|
|
20
|
+
fields: {
|
|
21
|
+
request_id: bcs.Address,
|
|
22
|
+
utxo_id: UtxoId,
|
|
23
|
+
amount: bcs.u64(),
|
|
24
|
+
derivation_path: bcs.option(bcs.Address),
|
|
25
|
+
timestamp_ms: bcs.u64(),
|
|
26
|
+
requester_address: bcs.Address,
|
|
27
|
+
sui_tx_digest: bcs.vector(bcs.u8())
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const DepositApprovedEvent = new MoveStruct({
|
|
31
|
+
name: `${$moduleName}::DepositApprovedEvent`,
|
|
32
|
+
fields: {
|
|
33
|
+
request_id: bcs.Address,
|
|
34
|
+
utxo: Utxo,
|
|
35
|
+
cert: CommitteeSignature,
|
|
36
|
+
approval_timestamp_ms: bcs.u64()
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const DepositConfirmedEvent = new MoveStruct({
|
|
40
|
+
name: `${$moduleName}::DepositConfirmedEvent`,
|
|
41
|
+
fields: {
|
|
42
|
+
request_id: bcs.Address,
|
|
43
|
+
utxo: Utxo
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const ExpiredDepositDeletedEvent = new MoveStruct({
|
|
47
|
+
name: `${$moduleName}::ExpiredDepositDeletedEvent`,
|
|
48
|
+
fields: { request_id: bcs.Address }
|
|
49
|
+
});
|
|
50
|
+
function deposit(options) {
|
|
51
|
+
const packageAddress = options.package ?? "@local-pkg/hashi";
|
|
52
|
+
const argumentsTypes = [
|
|
53
|
+
null,
|
|
54
|
+
null,
|
|
55
|
+
"0x2::clock::Clock"
|
|
56
|
+
];
|
|
57
|
+
const parameterNames = ["hashi", "utxo"];
|
|
58
|
+
return (tx) => tx.moveCall({
|
|
59
|
+
package: packageAddress,
|
|
60
|
+
module: "deposit",
|
|
61
|
+
function: "deposit",
|
|
62
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { deposit };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
+
import { ObjectBag } from "./deps/sui/object_bag.mjs";
|
|
3
|
+
import { Utxo } from "./utxo.mjs";
|
|
4
|
+
import { CommitteeSignature } from "./committee.mjs";
|
|
5
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
6
|
+
|
|
7
|
+
//#region src/contracts/hashi/deposit_queue.ts
|
|
8
|
+
/**************************************************************
|
|
9
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
10
|
+
**************************************************************/
|
|
11
|
+
const $moduleName = "@local-pkg/hashi::deposit_queue";
|
|
12
|
+
const DepositRequestQueue = new MoveStruct({
|
|
13
|
+
name: `${$moduleName}::DepositRequestQueue`,
|
|
14
|
+
fields: {
|
|
15
|
+
requests: ObjectBag,
|
|
16
|
+
processed: ObjectBag
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const DepositRequest = new MoveStruct({
|
|
20
|
+
name: `${$moduleName}::DepositRequest`,
|
|
21
|
+
fields: {
|
|
22
|
+
id: bcs.Address,
|
|
23
|
+
sender: bcs.Address,
|
|
24
|
+
timestamp_ms: bcs.u64(),
|
|
25
|
+
sui_tx_digest: bcs.vector(bcs.u8()),
|
|
26
|
+
utxo: Utxo,
|
|
27
|
+
approval_cert: bcs.option(CommitteeSignature),
|
|
28
|
+
approval_timestamp_ms: bcs.option(bcs.u64())
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { DepositRequest, DepositRequestQueue };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/deps/sui/bag.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* A bag is a heterogeneous map-like collection. The collection is similar to
|
|
10
|
+
* `sui::table` in that its keys and values are not stored within the `Bag` value,
|
|
11
|
+
* but instead are stored using Sui's object system. The `Bag` struct acts only as
|
|
12
|
+
* a handle into the object system to retrieve those keys and values. Note that
|
|
13
|
+
* this means that `Bag` values with exactly the same key-value mapping will not be
|
|
14
|
+
* equal, with `==`, at runtime. For example
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* let bag1 = bag::new();
|
|
18
|
+
* let bag2 = bag::new();
|
|
19
|
+
* bag::add(&mut bag1, 0, false);
|
|
20
|
+
* bag::add(&mut bag1, 1, true);
|
|
21
|
+
* bag::add(&mut bag2, 0, false);
|
|
22
|
+
* bag::add(&mut bag2, 1, true);
|
|
23
|
+
* // bag1 does not equal bag2, despite having the same entries
|
|
24
|
+
* assert!(&bag1 != &bag2);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* At it's core, `sui::bag` is a wrapper around `UID` that allows for access to
|
|
28
|
+
* `sui::dynamic_field` while preventing accidentally stranding field values. A
|
|
29
|
+
* `UID` can be deleted, even if it has dynamic fields associated with it, but a
|
|
30
|
+
* bag, on the other hand, must be empty to be destroyed.
|
|
31
|
+
*/
|
|
32
|
+
const $moduleName = "0x2::bag";
|
|
33
|
+
const Bag = new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::Bag`,
|
|
35
|
+
fields: {
|
|
36
|
+
id: bcs.Address,
|
|
37
|
+
size: bcs.u64()
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Bag };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/deps/sui/balance.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* A storable handler for Balances in general. Is used in the `Coin` module to
|
|
10
|
+
* allow balance operations and can be used to implement custom coins with `Supply`
|
|
11
|
+
* and `Balance`s.
|
|
12
|
+
*/
|
|
13
|
+
const $moduleName = "0x2::balance";
|
|
14
|
+
const Balance = new MoveStruct({
|
|
15
|
+
name: `${$moduleName}::Balance<phantom T>`,
|
|
16
|
+
fields: { value: bcs.u64() }
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Balance };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/deps/sui/group_ops.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/** Generic Move and native functions for group operations. */
|
|
9
|
+
const $moduleName = "0x2::group_ops";
|
|
10
|
+
const Element = new MoveStruct({
|
|
11
|
+
name: `${$moduleName}::Element<phantom T>`,
|
|
12
|
+
fields: { bytes: bcs.vector(bcs.u8()) }
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Element };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/deps/sui/object_bag.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* Similar to `sui::bag`, an `ObjectBag` is a heterogeneous map-like collection.
|
|
10
|
+
* But unlike `sui::bag`, the values bound to these dynamic fields _must_ be
|
|
11
|
+
* objects themselves. This allows for the objects to still exist in storage, which
|
|
12
|
+
* may be important for external tools. The difference is otherwise not observable
|
|
13
|
+
* from within Move.
|
|
14
|
+
*/
|
|
15
|
+
const $moduleName = "0x2::object_bag";
|
|
16
|
+
const ObjectBag = new MoveStruct({
|
|
17
|
+
name: `${$moduleName}::ObjectBag`,
|
|
18
|
+
fields: {
|
|
19
|
+
id: bcs.Address,
|
|
20
|
+
size: bcs.u64()
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ObjectBag };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/deps/sui/package.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* Functions for operating on Move packages from within Move:
|
|
10
|
+
*
|
|
11
|
+
* - Creating proof-of-publish objects from one-time witnesses
|
|
12
|
+
* - Administering package upgrades through upgrade policies.
|
|
13
|
+
*/
|
|
14
|
+
const $moduleName = "0x2::package";
|
|
15
|
+
const UpgradeCap = new MoveStruct({
|
|
16
|
+
name: `${$moduleName}::UpgradeCap`,
|
|
17
|
+
fields: {
|
|
18
|
+
id: bcs.Address,
|
|
19
|
+
package: bcs.Address,
|
|
20
|
+
version: bcs.u64(),
|
|
21
|
+
policy: bcs.u8()
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { UpgradeCap };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/deps/sui/table.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* A table is a map-like collection. But unlike a traditional collection, it's keys
|
|
10
|
+
* and values are not stored within the `Table` value, but instead are stored using
|
|
11
|
+
* Sui's object system. The `Table` struct acts only as a handle into the object
|
|
12
|
+
* system to retrieve those keys and values. Note that this means that `Table`
|
|
13
|
+
* values with exactly the same key-value mapping will not be equal, with `==`, at
|
|
14
|
+
* runtime. For example
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* let table1 = table::new<u64, bool>();
|
|
18
|
+
* let table2 = table::new<u64, bool>();
|
|
19
|
+
* table::add(&mut table1, 0, false);
|
|
20
|
+
* table::add(&mut table1, 1, true);
|
|
21
|
+
* table::add(&mut table2, 0, false);
|
|
22
|
+
* table::add(&mut table2, 1, true);
|
|
23
|
+
* // table1 does not equal table2, despite having the same entries
|
|
24
|
+
* assert!(&table1 != &table2);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const $moduleName = "0x2::table";
|
|
28
|
+
const Table = new MoveStruct({
|
|
29
|
+
name: `${$moduleName}::Table<phantom K, phantom V>`,
|
|
30
|
+
fields: {
|
|
31
|
+
id: bcs.Address,
|
|
32
|
+
size: bcs.u64()
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Table };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/deps/sui/vec_map.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
const $moduleName = "0x2::vec_map";
|
|
9
|
+
/** An entry in the map */
|
|
10
|
+
function Entry(...typeParameters) {
|
|
11
|
+
return new MoveStruct({
|
|
12
|
+
name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`,
|
|
13
|
+
fields: {
|
|
14
|
+
key: typeParameters[0],
|
|
15
|
+
value: typeParameters[1]
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A map data structure backed by a vector. The map is guaranteed not to contain
|
|
21
|
+
* duplicate keys, but entries are _not_ sorted by key--entries are included in
|
|
22
|
+
* insertion order. All operations are O(N) in the size of the map--the intention
|
|
23
|
+
* of this data structure is only to provide the convenience of programming against
|
|
24
|
+
* a map API. Large maps should use handwritten parent/child relationships instead.
|
|
25
|
+
* Maps that need sorted iteration rather than insertion order iteration should
|
|
26
|
+
* also be handwritten.
|
|
27
|
+
*/
|
|
28
|
+
function VecMap(...typeParameters) {
|
|
29
|
+
return new MoveStruct({
|
|
30
|
+
name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`,
|
|
31
|
+
fields: { contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { VecMap };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/deps/sui/vec_set.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
const $moduleName = "0x2::vec_set";
|
|
9
|
+
/**
|
|
10
|
+
* A set data structure backed by a vector. The set is guaranteed not to contain
|
|
11
|
+
* duplicate keys. All operations are O(N) in the size of the set
|
|
12
|
+
*
|
|
13
|
+
* - the intention of this data structure is only to provide the convenience of
|
|
14
|
+
* programming against a set API. Sets that need sorted iteration rather than
|
|
15
|
+
* insertion order iteration should be handwritten.
|
|
16
|
+
*/
|
|
17
|
+
function VecSet(...typeParameters) {
|
|
18
|
+
return new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::VecSet<${typeParameters[0].name}>`,
|
|
20
|
+
fields: { contents: bcs.vector(typeParameters[0]) }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { VecSet };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
+
import { Bag } from "./deps/sui/bag.mjs";
|
|
3
|
+
import { CommitteeSet } from "./committee_set.mjs";
|
|
4
|
+
import { Config } from "./config.mjs";
|
|
5
|
+
import { Treasury } from "./treasury.mjs";
|
|
6
|
+
import { Proposals } from "./proposals.mjs";
|
|
7
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
8
|
+
|
|
9
|
+
//#region src/contracts/hashi/hashi.ts
|
|
10
|
+
/**************************************************************
|
|
11
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
12
|
+
**************************************************************/
|
|
13
|
+
/** Module: hashi */
|
|
14
|
+
const $moduleName = "@local-pkg/hashi::hashi";
|
|
15
|
+
const Hashi = new MoveStruct({
|
|
16
|
+
name: `${$moduleName}::Hashi`,
|
|
17
|
+
fields: {
|
|
18
|
+
id: bcs.Address,
|
|
19
|
+
committee_set: CommitteeSet,
|
|
20
|
+
config: Config,
|
|
21
|
+
treasury: Treasury,
|
|
22
|
+
proposals: Proposals,
|
|
23
|
+
tob: Bag,
|
|
24
|
+
num_consumed_presigs: bcs.u64()
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Hashi };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
+
import { ObjectBag } from "./deps/sui/object_bag.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/proposals.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
const $moduleName = "@local-pkg/hashi::proposals";
|
|
9
|
+
const Proposals = new MoveStruct({
|
|
10
|
+
name: `${$moduleName}::Proposals`,
|
|
11
|
+
fields: {
|
|
12
|
+
active: ObjectBag,
|
|
13
|
+
executed: ObjectBag
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Proposals };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
+
import { ObjectBag } from "./deps/sui/object_bag.mjs";
|
|
3
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
4
|
+
|
|
5
|
+
//#region src/contracts/hashi/treasury.ts
|
|
6
|
+
/**************************************************************
|
|
7
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
8
|
+
**************************************************************/
|
|
9
|
+
const $moduleName = "@local-pkg/hashi::treasury";
|
|
10
|
+
const Treasury = new MoveStruct({
|
|
11
|
+
name: `${$moduleName}::Treasury`,
|
|
12
|
+
fields: { objects: ObjectBag }
|
|
13
|
+
});
|
|
14
|
+
const Key = new MoveStruct({
|
|
15
|
+
name: `${$moduleName}::Key<phantom T>`,
|
|
16
|
+
fields: { dummy_field: bcs.bool() }
|
|
17
|
+
});
|
|
18
|
+
const MintEvent = new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::MintEvent<phantom T>`,
|
|
20
|
+
fields: { amount: bcs.u64() }
|
|
21
|
+
});
|
|
22
|
+
const BurnEvent = new MoveStruct({
|
|
23
|
+
name: `${$moduleName}::BurnEvent<phantom T>`,
|
|
24
|
+
fields: { amount: bcs.u64() }
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Treasury };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/hashi/utxo.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
const $moduleName = "@local-pkg/hashi::utxo";
|
|
9
|
+
const UtxoId = new MoveStruct({
|
|
10
|
+
name: `${$moduleName}::UtxoId`,
|
|
11
|
+
fields: {
|
|
12
|
+
txid: bcs.Address,
|
|
13
|
+
vout: bcs.u32()
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const Utxo = new MoveStruct({
|
|
17
|
+
name: `${$moduleName}::Utxo`,
|
|
18
|
+
fields: {
|
|
19
|
+
id: UtxoId,
|
|
20
|
+
amount: bcs.u64(),
|
|
21
|
+
derivation_path: bcs.option(bcs.Address)
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
function utxoId(options) {
|
|
25
|
+
const packageAddress = options.package ?? "@local-pkg/hashi";
|
|
26
|
+
const argumentsTypes = ["address", "u32"];
|
|
27
|
+
const parameterNames = ["txid", "vout"];
|
|
28
|
+
return (tx) => tx.moveCall({
|
|
29
|
+
package: packageAddress,
|
|
30
|
+
module: "utxo",
|
|
31
|
+
function: "utxo_id",
|
|
32
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function utxo(options) {
|
|
36
|
+
const packageAddress = options.package ?? "@local-pkg/hashi";
|
|
37
|
+
const argumentsTypes = [
|
|
38
|
+
null,
|
|
39
|
+
"u64",
|
|
40
|
+
"0x1::option::Option<address>"
|
|
41
|
+
];
|
|
42
|
+
const parameterNames = [
|
|
43
|
+
"utxoId",
|
|
44
|
+
"amount",
|
|
45
|
+
"derivationPath"
|
|
46
|
+
];
|
|
47
|
+
return (tx) => tx.moveCall({
|
|
48
|
+
package: packageAddress,
|
|
49
|
+
module: "utxo",
|
|
50
|
+
function: "utxo",
|
|
51
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Utxo, UtxoId, utxo, utxoId };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
+
import { Bag } from "./deps/sui/bag.mjs";
|
|
3
|
+
import { Utxo, UtxoId } from "./utxo.mjs";
|
|
4
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
5
|
+
|
|
6
|
+
//#region src/contracts/hashi/utxo_pool.ts
|
|
7
|
+
/**************************************************************
|
|
8
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
9
|
+
**************************************************************/
|
|
10
|
+
const $moduleName = "@local-pkg/hashi::utxo_pool";
|
|
11
|
+
const UtxoPool = new MoveStruct({
|
|
12
|
+
name: `${$moduleName}::UtxoPool`,
|
|
13
|
+
fields: {
|
|
14
|
+
utxo_records: Bag,
|
|
15
|
+
spent_utxos: Bag
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const UtxoRecord = new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::UtxoRecord`,
|
|
20
|
+
fields: {
|
|
21
|
+
utxo: Utxo,
|
|
22
|
+
produced_by: bcs.option(bcs.Address),
|
|
23
|
+
locked_by: bcs.option(bcs.Address)
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const UtxoSpentEvent = new MoveStruct({
|
|
27
|
+
name: `${$moduleName}::UtxoSpentEvent`,
|
|
28
|
+
fields: {
|
|
29
|
+
utxo_id: UtxoId,
|
|
30
|
+
spent_epoch: bcs.u64()
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { UtxoPool };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
|
|
2
|
+
import { UtxoId } from "./utxo.mjs";
|
|
3
|
+
import { OutputUtxo } from "./withdrawal_queue.mjs";
|
|
4
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
5
|
+
|
|
6
|
+
//#region src/contracts/hashi/withdraw.ts
|
|
7
|
+
/**************************************************************
|
|
8
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
9
|
+
**************************************************************/
|
|
10
|
+
/** Module: withdraw */
|
|
11
|
+
const $moduleName = "@local-pkg/hashi::withdraw";
|
|
12
|
+
const RequestApprovalMessage = new MoveStruct({
|
|
13
|
+
name: `${$moduleName}::RequestApprovalMessage`,
|
|
14
|
+
fields: { request_id: bcs.Address }
|
|
15
|
+
});
|
|
16
|
+
const WithdrawalCommitmentMessage = new MoveStruct({
|
|
17
|
+
name: `${$moduleName}::WithdrawalCommitmentMessage`,
|
|
18
|
+
fields: {
|
|
19
|
+
request_ids: bcs.vector(bcs.Address),
|
|
20
|
+
selected_utxos: bcs.vector(UtxoId),
|
|
21
|
+
outputs: bcs.vector(OutputUtxo),
|
|
22
|
+
txid: bcs.Address
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const WithdrawalSignedMessage = new MoveStruct({
|
|
26
|
+
name: `${$moduleName}::WithdrawalSignedMessage`,
|
|
27
|
+
fields: {
|
|
28
|
+
withdrawal_id: bcs.Address,
|
|
29
|
+
request_ids: bcs.vector(bcs.Address),
|
|
30
|
+
signatures: bcs.vector(bcs.vector(bcs.u8()))
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const WithdrawalConfirmationMessage = new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::WithdrawalConfirmationMessage`,
|
|
35
|
+
fields: { withdrawal_id: bcs.Address }
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Request a withdrawal of BTC from the bridge.
|
|
39
|
+
*
|
|
40
|
+
* The full BTC amount is stored in the withdrawal request. The miner fee is
|
|
41
|
+
* deducted later at commitment time.
|
|
42
|
+
*
|
|
43
|
+
* The user must provide at least `bitcoin_withdrawal_minimum()` sats, which
|
|
44
|
+
* guarantees the amount covers worst-case miner fees plus dust.
|
|
45
|
+
*/
|
|
46
|
+
function requestWithdrawal(options) {
|
|
47
|
+
const packageAddress = options.package ?? "@local-pkg/hashi";
|
|
48
|
+
const argumentsTypes = [
|
|
49
|
+
null,
|
|
50
|
+
"0x2::clock::Clock",
|
|
51
|
+
null,
|
|
52
|
+
"vector<u8>"
|
|
53
|
+
];
|
|
54
|
+
const parameterNames = [
|
|
55
|
+
"hashi",
|
|
56
|
+
"btc",
|
|
57
|
+
"bitcoinAddress"
|
|
58
|
+
];
|
|
59
|
+
return (tx) => tx.moveCall({
|
|
60
|
+
package: packageAddress,
|
|
61
|
+
module: "withdraw",
|
|
62
|
+
function: "request_withdrawal",
|
|
63
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Cancel a pending withdrawal request and return the stored BTC to the requester.
|
|
68
|
+
*
|
|
69
|
+
* Cancellation is allowed while the request is in the `Requested` or `Approved`
|
|
70
|
+
* state (i.e. still in the active requests bag). Once the committee commits the
|
|
71
|
+
* request to a `WithdrawalTransaction` it moves to `Processing` in the processed
|
|
72
|
+
* bag and its BTC is burned — cancellation is no longer possible.
|
|
73
|
+
*/
|
|
74
|
+
function cancelWithdrawal(options) {
|
|
75
|
+
const packageAddress = options.package ?? "@local-pkg/hashi";
|
|
76
|
+
const argumentsTypes = [
|
|
77
|
+
null,
|
|
78
|
+
"address",
|
|
79
|
+
"0x2::clock::Clock"
|
|
80
|
+
];
|
|
81
|
+
const parameterNames = ["hashi", "requestId"];
|
|
82
|
+
return (tx) => tx.moveCall({
|
|
83
|
+
package: packageAddress,
|
|
84
|
+
module: "withdraw",
|
|
85
|
+
function: "cancel_withdrawal",
|
|
86
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { cancelWithdrawal, requestWithdrawal };
|