-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.mo
172 lines (146 loc) · 4.33 KB
/
types.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import Time "mo:base/Time";
import Curves "./motoko-bitcoin/src/ec/Curves";
module {
public type NFTInfo = {
number : Nat;
priceE8S : ?Nat;
priceSatoshi : ?Nat;
};
public type TokenAmount = Nat64;
public type AccountId = Blob;
public type AccountIdText = Text;
public type Subaccount = Nat;
public type SubaccountNat8Arr = [Nat8];
public type SubaccountBlob = Blob;
public type SubaccountStatus = {
#empty; // empty and waiting for a transfer
#cancelled; // transfer has been cancelled
#confirmed; // transfer has been confirmed by frontend,
// now we need to check that we recieved the funds
#funded; // funds recieved
};
public type SubaccountNetwork = Text; // "ICP" or "BTC"
public type TransferRequest = {
info: Text;
from: ?SubaccountNat8Arr;
to: AccountIdText;
amount: TokenAmount;
network: SubaccountNetwork;
};
// PROJECT
public type ProjectId = Nat;
public type ProjectStatus = {
#whitelist;
#live;
#fully_funded;
};
// LEDGER
public type AccountBalanceArgs = { account : AccountIdText };
public type ICPTs = { e8s : TokenAmount };
public type SendArgs = {
memo : Nat64;
amount : ICPTs;
fee : ICPTs;
from_subaccount : ?SubaccountNat8Arr;
to : AccountIdText;
created_at_time : ?Time.Time;
};
// ESCROW STATS
public type NFTStats = {
number : Nat;
priceE8S : Nat;
priceSatoshi : Nat;
sold : Nat;
openSubaccounts : Nat;
oversellNumber : Int;
};
public type EscrowStats = {
endTime : Time.Time;
nftStats : [NFTStats];
};
// BTC
public type SendRequest = {
destination_address : Text;
amount_in_satoshi : Satoshi;
};
public type ECDSAPublicKeyReply = {
public_key : Blob;
chain_code : Blob;
};
public type EcdsaKeyId = {
curve : EcdsaCurve;
name : Text;
};
public type EcdsaCurve = {
#secp256k1;
};
public type SignWithECDSAReply = {
signature : Blob;
};
public type ECDSAPublicKey = {
canister_id : ?Principal;
derivation_path : [Blob];
key_id : EcdsaKeyId;
};
public type SignWithECDSA = {
message_hash : Blob;
derivation_path : [Blob];
key_id : EcdsaKeyId;
};
public type Satoshi = Nat64;
public type MillisatoshiPerByte = Nat64;
public type Cycles = Nat;
public type BitcoinAddress = Text;
public type BlockHash = [Nat8];
public type Page = [Nat8];
public let CURVE = Curves.secp256k1;
/// The type of Bitcoin network the dapp will be interacting with.
public type Network = {
#Mainnet;
#Testnet;
#Regtest;
};
/// A reference to a transaction output.
public type OutPoint = {
txid : Blob;
vout : Nat32;
};
/// An unspent transaction output.
public type Utxo = {
outpoint : OutPoint;
value : Satoshi;
height : Nat32;
};
/// A request for getting the balance for a given address.
public type GetBalanceRequest = {
address : BitcoinAddress;
network : Network;
min_confirmations : ?Nat32;
};
/// A filter used when requesting UTXOs.
public type UtxosFilter = {
#MinConfirmations : Nat32;
#Page : Page;
};
/// A request for getting the UTXOs for a given address.
public type GetUtxosRequest = {
address : BitcoinAddress;
network : Network;
filter : ?UtxosFilter;
};
/// The response returned for a request to get the UTXOs of a given address.
public type GetUtxosResponse = {
utxos : [Utxo];
tip_block_hash : BlockHash;
tip_height : Nat32;
next_page : ?Page;
};
/// A request for getting the current fee percentiles.
public type GetCurrentFeePercentilesRequest = {
network : Network;
};
public type SendTransactionRequest = {
transaction : [Nat8];
network : Network;
};
};