@junobuild/admin 0.0.12 → 0.0.14
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 +1 -1
- package/declarations/cmc/cmc.did +122 -0
- package/declarations/cmc/cmc.did.d.ts +48 -0
- package/declarations/cmc/cmc.factory.did.js +65 -0
- package/declarations/cmc/index.d.ts +45 -0
- package/declarations/cmc/index.js +32 -0
- package/declarations/console/console.did.d.ts +60 -0
- package/declarations/console/console.factory.did.js +62 -0
- package/declarations/console/console.factory.did.mjs +62 -0
- package/declarations/console/index.d.ts +45 -0
- package/declarations/console/index.js +32 -0
- package/declarations/frontend/frontend.did +188 -0
- package/declarations/frontend/frontend.did.d.ts +172 -0
- package/declarations/frontend/frontend.factory.did.js +208 -0
- package/declarations/frontend/index.d.ts +45 -0
- package/declarations/frontend/index.js +32 -0
- package/declarations/ic/ic.did +82 -0
- package/declarations/ic/ic.did.d.ts +77 -0
- package/declarations/ic/ic.factory.did.js +128 -0
- package/declarations/internet_identity/index.d.ts +45 -0
- package/declarations/internet_identity/index.js +32 -0
- package/declarations/internet_identity/internet_identity.did +330 -0
- package/declarations/internet_identity/internet_identity.did.d.ts +204 -0
- package/declarations/internet_identity/internet_identity.factory.did.js +233 -0
- package/declarations/ledger/index.d.ts +45 -0
- package/declarations/ledger/index.js +32 -0
- package/declarations/ledger/ledger.did +249 -0
- package/declarations/ledger/ledger.did.d.ts +100 -0
- package/declarations/ledger/ledger.factory.did.js +98 -0
- package/declarations/mission_control/index.d.ts +45 -0
- package/declarations/mission_control/index.js +32 -0
- package/declarations/mission_control/mission_control.did.d.ts +41 -0
- package/declarations/mission_control/mission_control.factory.did.js +50 -0
- package/declarations/satellite/index.d.ts +45 -0
- package/declarations/satellite/index.js +32 -0
- package/declarations/satellite/satellite-deprecated.did.d.ts +182 -0
- package/declarations/satellite/satellite-deprecated.factory.did.js +191 -0
- package/declarations/satellite/satellite-deprecated.factory.did.mjs +191 -0
- package/declarations/satellite/satellite.did.d.ts +183 -0
- package/declarations/satellite/satellite.factory.did.js +194 -0
- package/declarations/satellite/satellite.factory.did.mjs +192 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +2 -2
- package/package.json +3 -3
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// This is the official Ledger interface that is guaranteed to be backward compatible.
|
|
2
|
+
|
|
3
|
+
// Amount of tokens, measured in 10^-8 of a token.
|
|
4
|
+
type Tokens = record {
|
|
5
|
+
e8s : nat64;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// Number of nanoseconds from the UNIX epoch in UTC timezone.
|
|
9
|
+
type TimeStamp = record {
|
|
10
|
+
timestamp_nanos: nat64;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// AccountIdentifier is a 32-byte array.
|
|
14
|
+
// The first 4 bytes is big-endian encoding of a CRC32 checksum of the last 28 bytes.
|
|
15
|
+
type AccountIdentifier = blob;
|
|
16
|
+
|
|
17
|
+
// Subaccount is an arbitrary 32-byte byte array.
|
|
18
|
+
// Ledger uses subaccounts to compute the source address, which enables one
|
|
19
|
+
// principal to control multiple ledger accounts.
|
|
20
|
+
type SubAccount = blob;
|
|
21
|
+
|
|
22
|
+
// Sequence number of a block produced by the ledger.
|
|
23
|
+
type BlockIndex = nat64;
|
|
24
|
+
|
|
25
|
+
// An arbitrary number associated with a transaction.
|
|
26
|
+
// The caller can set it in a `transfer` call as a correlation identifier.
|
|
27
|
+
type Memo = nat64;
|
|
28
|
+
|
|
29
|
+
// Arguments for the `transfer` call.
|
|
30
|
+
type TransferArgs = record {
|
|
31
|
+
// Transaction memo.
|
|
32
|
+
// See comments for the `Memo` type.
|
|
33
|
+
memo: Memo;
|
|
34
|
+
// The amount that the caller wants to transfer to the destination address.
|
|
35
|
+
amount: Tokens;
|
|
36
|
+
// The amount that the caller pays for the transaction.
|
|
37
|
+
// Must be 10000 e8s.
|
|
38
|
+
fee: Tokens;
|
|
39
|
+
// The subaccount from which the caller wants to transfer funds.
|
|
40
|
+
// If null, the ledger uses the default (all zeros) subaccount to compute the source address.
|
|
41
|
+
// See comments for the `SubAccount` type.
|
|
42
|
+
from_subaccount: opt SubAccount;
|
|
43
|
+
// The destination account.
|
|
44
|
+
// If the transfer is successful, the balance of this address increases by `amount`.
|
|
45
|
+
to: AccountIdentifier;
|
|
46
|
+
// The point in time when the caller created this request.
|
|
47
|
+
// If null, the ledger uses current IC time as the timestamp.
|
|
48
|
+
created_at_time: opt TimeStamp;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type TransferError = variant {
|
|
52
|
+
// The fee that the caller specified in the transfer request was not the one that ledger expects.
|
|
53
|
+
// The caller can change the transfer fee to the `expected_fee` and retry the request.
|
|
54
|
+
BadFee : record { expected_fee : Tokens; };
|
|
55
|
+
// The account specified by the caller doesn't have enough funds.
|
|
56
|
+
InsufficientFunds : record { balance: Tokens; };
|
|
57
|
+
// The request is too old.
|
|
58
|
+
// The ledger only accepts requests created within 24 hours window.
|
|
59
|
+
// This is a non-recoverable error.
|
|
60
|
+
TxTooOld : record { allowed_window_nanos: nat64 };
|
|
61
|
+
// The caller specified `created_at_time` that is too far in future.
|
|
62
|
+
// The caller can retry the request later.
|
|
63
|
+
TxCreatedInFuture : null;
|
|
64
|
+
// The ledger has already executed the request.
|
|
65
|
+
// `duplicate_of` field is equal to the index of the block containing the original transaction.
|
|
66
|
+
TxDuplicate : record { duplicate_of: BlockIndex; }
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
type TransferResult = variant {
|
|
70
|
+
Ok : BlockIndex;
|
|
71
|
+
Err : TransferError;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Arguments for the `account_balance` call.
|
|
75
|
+
type AccountBalanceArgs = record {
|
|
76
|
+
account: AccountIdentifier;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type TransferFeeArg = record {};
|
|
80
|
+
|
|
81
|
+
type TransferFee = record {
|
|
82
|
+
// The fee to pay to perform a transfer
|
|
83
|
+
transfer_fee: Tokens;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
type GetBlocksArgs = record {
|
|
87
|
+
// The index of the first block to fetch.
|
|
88
|
+
start : BlockIndex;
|
|
89
|
+
// Max number of blocks to fetch.
|
|
90
|
+
length : nat64;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type Operation = variant {
|
|
94
|
+
Mint : record {
|
|
95
|
+
to : AccountIdentifier;
|
|
96
|
+
amount : Tokens;
|
|
97
|
+
};
|
|
98
|
+
Burn : record {
|
|
99
|
+
from : AccountIdentifier;
|
|
100
|
+
amount : Tokens;
|
|
101
|
+
};
|
|
102
|
+
Transfer : record {
|
|
103
|
+
from : AccountIdentifier;
|
|
104
|
+
to : AccountIdentifier;
|
|
105
|
+
amount : Tokens;
|
|
106
|
+
fee : Tokens;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
type Transaction = record {
|
|
111
|
+
memo : Memo;
|
|
112
|
+
operation : opt Operation;
|
|
113
|
+
created_at_time : TimeStamp;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
type Block = record {
|
|
117
|
+
parent_hash : opt blob;
|
|
118
|
+
transaction : Transaction;
|
|
119
|
+
timestamp : TimeStamp;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// A prefix of the block range specified in the [GetBlocksArgs] request.
|
|
123
|
+
type BlockRange = record {
|
|
124
|
+
// A prefix of the requested block range.
|
|
125
|
+
// The index of the first block is equal to [GetBlocksArgs.from].
|
|
126
|
+
//
|
|
127
|
+
// Note that the number of blocks might be less than the requested
|
|
128
|
+
// [GetBlocksArgs.len] for various reasons, for example:
|
|
129
|
+
//
|
|
130
|
+
// 1. The query might have hit the replica with an outdated state
|
|
131
|
+
// that doesn't have the full block range yet.
|
|
132
|
+
// 2. The requested range is too large to fit into a single reply.
|
|
133
|
+
//
|
|
134
|
+
// NOTE: the list of blocks can be empty if:
|
|
135
|
+
// 1. [GetBlocksArgs.len] was zero.
|
|
136
|
+
// 2. [GetBlocksArgs.from] was larger than the last block known to the canister.
|
|
137
|
+
blocks : vec Block;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// An error indicating that the arguments passed to [QueryArchiveFn] were invalid.
|
|
141
|
+
type QueryArchiveError = variant {
|
|
142
|
+
// [GetBlocksArgs.from] argument was smaller than the first block
|
|
143
|
+
// served by the canister that received the request.
|
|
144
|
+
BadFirstBlockIndex : record {
|
|
145
|
+
requested_index : BlockIndex;
|
|
146
|
+
first_valid_index : BlockIndex;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// Reserved for future use.
|
|
150
|
+
Other : record {
|
|
151
|
+
error_code : nat64;
|
|
152
|
+
error_message : text;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
type QueryArchiveResult = variant {
|
|
157
|
+
// Successfully fetched zero or more blocks.
|
|
158
|
+
Ok : BlockRange;
|
|
159
|
+
// The [GetBlocksArgs] request was invalid.
|
|
160
|
+
Err : QueryArchiveError;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// A function that is used for fetching archived ledger blocks.
|
|
164
|
+
type QueryArchiveFn = func (GetBlocksArgs) -> (QueryArchiveResult) query;
|
|
165
|
+
|
|
166
|
+
// The result of a "query_blocks" call.
|
|
167
|
+
//
|
|
168
|
+
// The structure of the result is somewhat complicated because the main ledger canister might
|
|
169
|
+
// not have all the blocks that the caller requested: One or more "archive" canisters might
|
|
170
|
+
// store some of the requested blocks.
|
|
171
|
+
//
|
|
172
|
+
// Note: as of Q4 2021 when this interface is authored, the IC doesn't support making nested
|
|
173
|
+
// query calls within a query call.
|
|
174
|
+
type QueryBlocksResponse = record {
|
|
175
|
+
// The total number of blocks in the chain.
|
|
176
|
+
// If the chain length is positive, the index of the last block is `chain_len - 1`.
|
|
177
|
+
chain_length : nat64;
|
|
178
|
+
|
|
179
|
+
// System certificate for the hash of the latest block in the chain.
|
|
180
|
+
// Only present if `query_blocks` is called in a non-replicated query context.
|
|
181
|
+
certificate : opt blob;
|
|
182
|
+
|
|
183
|
+
// List of blocks that were available in the ledger when it processed the call.
|
|
184
|
+
//
|
|
185
|
+
// The blocks form a contiguous range, with the first block having index
|
|
186
|
+
// [first_block_index] (see below), and the last block having index
|
|
187
|
+
// [first_block_index] + len(blocks) - 1.
|
|
188
|
+
//
|
|
189
|
+
// The block range can be an arbitrary sub-range of the originally requested range.
|
|
190
|
+
blocks : vec Block;
|
|
191
|
+
|
|
192
|
+
// The index of the first block in "blocks".
|
|
193
|
+
// If the blocks vector is empty, the exact value of this field is not specified.
|
|
194
|
+
first_block_index : BlockIndex;
|
|
195
|
+
|
|
196
|
+
// Encoding of instructions for fetching archived blocks whose indices fall into the
|
|
197
|
+
// requested range.
|
|
198
|
+
//
|
|
199
|
+
// For each entry `e` in [archived_blocks], `[e.from, e.from + len)` is a sub-range
|
|
200
|
+
// of the originally requested block range.
|
|
201
|
+
archived_blocks : vec record {
|
|
202
|
+
// The index of the first archived block that can be fetched using the callback.
|
|
203
|
+
start : BlockIndex;
|
|
204
|
+
|
|
205
|
+
// The number of blocks that can be fetch using the callback.
|
|
206
|
+
length : nat64;
|
|
207
|
+
|
|
208
|
+
// The function that should be called to fetch the archived blocks.
|
|
209
|
+
// The range of the blocks accessible using this function is given by [from]
|
|
210
|
+
// and [len] fields above.
|
|
211
|
+
callback : QueryArchiveFn;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
type Archive = record {
|
|
216
|
+
canister_id: principal;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
type Archives = record {
|
|
220
|
+
archives: vec Archive;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
service : {
|
|
224
|
+
// Transfers tokens from a subaccount of the caller to the destination address.
|
|
225
|
+
// The source address is computed from the principal of the caller and the specified subaccount.
|
|
226
|
+
// When successful, returns the index of the block containing the transaction.
|
|
227
|
+
transfer : (TransferArgs) -> (TransferResult);
|
|
228
|
+
|
|
229
|
+
// Returns the amount of Tokens on the specified account.
|
|
230
|
+
account_balance : (AccountBalanceArgs) -> (Tokens) query;
|
|
231
|
+
|
|
232
|
+
// Returns the current transfer_fee.
|
|
233
|
+
transfer_fee : (TransferFeeArg) -> (TransferFee) query;
|
|
234
|
+
|
|
235
|
+
// Queries blocks in the specified range.
|
|
236
|
+
query_blocks : (GetBlocksArgs) -> (QueryBlocksResponse) query;
|
|
237
|
+
|
|
238
|
+
// Returns token symbol.
|
|
239
|
+
symbol : () -> (record { symbol: text }) query;
|
|
240
|
+
|
|
241
|
+
// Returns token name.
|
|
242
|
+
name : () -> (record { name: text }) query;
|
|
243
|
+
|
|
244
|
+
// Returns token decimals.
|
|
245
|
+
decimals : () -> (record { decimals: nat32 }) query;
|
|
246
|
+
|
|
247
|
+
// Returns the existing archive canisters information.
|
|
248
|
+
archives : () -> (Archives) query;
|
|
249
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export interface AccountBalanceArgs {
|
|
5
|
+
account: AccountIdentifier;
|
|
6
|
+
}
|
|
7
|
+
export type AccountIdentifier = Uint8Array | number[];
|
|
8
|
+
export interface Archive {
|
|
9
|
+
canister_id: Principal;
|
|
10
|
+
}
|
|
11
|
+
export interface Archives {
|
|
12
|
+
archives: Array<Archive>;
|
|
13
|
+
}
|
|
14
|
+
export interface Block {
|
|
15
|
+
transaction: Transaction;
|
|
16
|
+
timestamp: TimeStamp;
|
|
17
|
+
parent_hash: [] | [Uint8Array | number[]];
|
|
18
|
+
}
|
|
19
|
+
export type BlockIndex = bigint;
|
|
20
|
+
export interface BlockRange {
|
|
21
|
+
blocks: Array<Block>;
|
|
22
|
+
}
|
|
23
|
+
export interface GetBlocksArgs {
|
|
24
|
+
start: BlockIndex;
|
|
25
|
+
length: bigint;
|
|
26
|
+
}
|
|
27
|
+
export type Memo = bigint;
|
|
28
|
+
export type Operation =
|
|
29
|
+
| {
|
|
30
|
+
Burn: {from: AccountIdentifier; amount: Tokens};
|
|
31
|
+
}
|
|
32
|
+
| {Mint: {to: AccountIdentifier; amount: Tokens}}
|
|
33
|
+
| {
|
|
34
|
+
Transfer: {
|
|
35
|
+
to: AccountIdentifier;
|
|
36
|
+
fee: Tokens;
|
|
37
|
+
from: AccountIdentifier;
|
|
38
|
+
amount: Tokens;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type QueryArchiveError =
|
|
42
|
+
| {
|
|
43
|
+
BadFirstBlockIndex: {
|
|
44
|
+
requested_index: BlockIndex;
|
|
45
|
+
first_valid_index: BlockIndex;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
| {Other: {error_message: string; error_code: bigint}};
|
|
49
|
+
export type QueryArchiveFn = ActorMethod<[GetBlocksArgs], QueryArchiveResult>;
|
|
50
|
+
export type QueryArchiveResult = {Ok: BlockRange} | {Err: QueryArchiveError};
|
|
51
|
+
export interface QueryBlocksResponse {
|
|
52
|
+
certificate: [] | [Uint8Array | number[]];
|
|
53
|
+
blocks: Array<Block>;
|
|
54
|
+
chain_length: bigint;
|
|
55
|
+
first_block_index: BlockIndex;
|
|
56
|
+
archived_blocks: Array<{callback: QueryArchiveFn; start: BlockIndex; length: bigint}>;
|
|
57
|
+
}
|
|
58
|
+
export type SubAccount = Uint8Array | number[];
|
|
59
|
+
export interface TimeStamp {
|
|
60
|
+
timestamp_nanos: bigint;
|
|
61
|
+
}
|
|
62
|
+
export interface Tokens {
|
|
63
|
+
e8s: bigint;
|
|
64
|
+
}
|
|
65
|
+
export interface Transaction {
|
|
66
|
+
memo: Memo;
|
|
67
|
+
operation: [] | [Operation];
|
|
68
|
+
created_at_time: TimeStamp;
|
|
69
|
+
}
|
|
70
|
+
export interface TransferArgs {
|
|
71
|
+
to: AccountIdentifier;
|
|
72
|
+
fee: Tokens;
|
|
73
|
+
memo: Memo;
|
|
74
|
+
from_subaccount: [] | [SubAccount];
|
|
75
|
+
created_at_time: [] | [TimeStamp];
|
|
76
|
+
amount: Tokens;
|
|
77
|
+
}
|
|
78
|
+
export type TransferError =
|
|
79
|
+
| {
|
|
80
|
+
TxTooOld: {allowed_window_nanos: bigint};
|
|
81
|
+
}
|
|
82
|
+
| {BadFee: {expected_fee: Tokens}}
|
|
83
|
+
| {TxDuplicate: {duplicate_of: BlockIndex}}
|
|
84
|
+
| {TxCreatedInFuture: null}
|
|
85
|
+
| {InsufficientFunds: {balance: Tokens}};
|
|
86
|
+
export interface TransferFee {
|
|
87
|
+
transfer_fee: Tokens;
|
|
88
|
+
}
|
|
89
|
+
export type TransferFeeArg = {};
|
|
90
|
+
export type TransferResult = {Ok: BlockIndex} | {Err: TransferError};
|
|
91
|
+
export interface _SERVICE {
|
|
92
|
+
account_balance: ActorMethod<[AccountBalanceArgs], Tokens>;
|
|
93
|
+
archives: ActorMethod<[], Archives>;
|
|
94
|
+
decimals: ActorMethod<[], {decimals: number}>;
|
|
95
|
+
name: ActorMethod<[], {name: string}>;
|
|
96
|
+
query_blocks: ActorMethod<[GetBlocksArgs], QueryBlocksResponse>;
|
|
97
|
+
symbol: ActorMethod<[], {symbol: string}>;
|
|
98
|
+
transfer: ActorMethod<[TransferArgs], TransferResult>;
|
|
99
|
+
transfer_fee: ActorMethod<[TransferFeeArg], TransferFee>;
|
|
100
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export const idlFactory = ({IDL}) => {
|
|
2
|
+
const AccountIdentifier = IDL.Vec(IDL.Nat8);
|
|
3
|
+
const AccountBalanceArgs = IDL.Record({account: AccountIdentifier});
|
|
4
|
+
const Tokens = IDL.Record({e8s: IDL.Nat64});
|
|
5
|
+
const Archive = IDL.Record({canister_id: IDL.Principal});
|
|
6
|
+
const Archives = IDL.Record({archives: IDL.Vec(Archive)});
|
|
7
|
+
const BlockIndex = IDL.Nat64;
|
|
8
|
+
const GetBlocksArgs = IDL.Record({
|
|
9
|
+
start: BlockIndex,
|
|
10
|
+
length: IDL.Nat64
|
|
11
|
+
});
|
|
12
|
+
const Memo = IDL.Nat64;
|
|
13
|
+
const Operation = IDL.Variant({
|
|
14
|
+
Burn: IDL.Record({from: AccountIdentifier, amount: Tokens}),
|
|
15
|
+
Mint: IDL.Record({to: AccountIdentifier, amount: Tokens}),
|
|
16
|
+
Transfer: IDL.Record({
|
|
17
|
+
to: AccountIdentifier,
|
|
18
|
+
fee: Tokens,
|
|
19
|
+
from: AccountIdentifier,
|
|
20
|
+
amount: Tokens
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
const TimeStamp = IDL.Record({timestamp_nanos: IDL.Nat64});
|
|
24
|
+
const Transaction = IDL.Record({
|
|
25
|
+
memo: Memo,
|
|
26
|
+
operation: IDL.Opt(Operation),
|
|
27
|
+
created_at_time: TimeStamp
|
|
28
|
+
});
|
|
29
|
+
const Block = IDL.Record({
|
|
30
|
+
transaction: Transaction,
|
|
31
|
+
timestamp: TimeStamp,
|
|
32
|
+
parent_hash: IDL.Opt(IDL.Vec(IDL.Nat8))
|
|
33
|
+
});
|
|
34
|
+
const BlockRange = IDL.Record({blocks: IDL.Vec(Block)});
|
|
35
|
+
const QueryArchiveError = IDL.Variant({
|
|
36
|
+
BadFirstBlockIndex: IDL.Record({
|
|
37
|
+
requested_index: BlockIndex,
|
|
38
|
+
first_valid_index: BlockIndex
|
|
39
|
+
}),
|
|
40
|
+
Other: IDL.Record({
|
|
41
|
+
error_message: IDL.Text,
|
|
42
|
+
error_code: IDL.Nat64
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
const QueryArchiveResult = IDL.Variant({
|
|
46
|
+
Ok: BlockRange,
|
|
47
|
+
Err: QueryArchiveError
|
|
48
|
+
});
|
|
49
|
+
const QueryArchiveFn = IDL.Func([GetBlocksArgs], [QueryArchiveResult], ['query']);
|
|
50
|
+
const QueryBlocksResponse = IDL.Record({
|
|
51
|
+
certificate: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
52
|
+
blocks: IDL.Vec(Block),
|
|
53
|
+
chain_length: IDL.Nat64,
|
|
54
|
+
first_block_index: BlockIndex,
|
|
55
|
+
archived_blocks: IDL.Vec(
|
|
56
|
+
IDL.Record({
|
|
57
|
+
callback: QueryArchiveFn,
|
|
58
|
+
start: BlockIndex,
|
|
59
|
+
length: IDL.Nat64
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
});
|
|
63
|
+
const SubAccount = IDL.Vec(IDL.Nat8);
|
|
64
|
+
const TransferArgs = IDL.Record({
|
|
65
|
+
to: AccountIdentifier,
|
|
66
|
+
fee: Tokens,
|
|
67
|
+
memo: Memo,
|
|
68
|
+
from_subaccount: IDL.Opt(SubAccount),
|
|
69
|
+
created_at_time: IDL.Opt(TimeStamp),
|
|
70
|
+
amount: Tokens
|
|
71
|
+
});
|
|
72
|
+
const TransferError = IDL.Variant({
|
|
73
|
+
TxTooOld: IDL.Record({allowed_window_nanos: IDL.Nat64}),
|
|
74
|
+
BadFee: IDL.Record({expected_fee: Tokens}),
|
|
75
|
+
TxDuplicate: IDL.Record({duplicate_of: BlockIndex}),
|
|
76
|
+
TxCreatedInFuture: IDL.Null,
|
|
77
|
+
InsufficientFunds: IDL.Record({balance: Tokens})
|
|
78
|
+
});
|
|
79
|
+
const TransferResult = IDL.Variant({
|
|
80
|
+
Ok: BlockIndex,
|
|
81
|
+
Err: TransferError
|
|
82
|
+
});
|
|
83
|
+
const TransferFeeArg = IDL.Record({});
|
|
84
|
+
const TransferFee = IDL.Record({transfer_fee: Tokens});
|
|
85
|
+
return IDL.Service({
|
|
86
|
+
account_balance: IDL.Func([AccountBalanceArgs], [Tokens], ['query']),
|
|
87
|
+
archives: IDL.Func([], [Archives], ['query']),
|
|
88
|
+
decimals: IDL.Func([], [IDL.Record({decimals: IDL.Nat32})], ['query']),
|
|
89
|
+
name: IDL.Func([], [IDL.Record({name: IDL.Text})], ['query']),
|
|
90
|
+
query_blocks: IDL.Func([GetBlocksArgs], [QueryBlocksResponse], ['query']),
|
|
91
|
+
symbol: IDL.Func([], [IDL.Record({symbol: IDL.Text})], ['query']),
|
|
92
|
+
transfer: IDL.Func([TransferArgs], [TransferResult], []),
|
|
93
|
+
transfer_fee: IDL.Func([TransferFeeArg], [TransferFee], ['query'])
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
export const init = ({IDL}) => {
|
|
97
|
+
return [];
|
|
98
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {ActorConfig, ActorSubclass, Agent, HttpAgentOptions} from '@dfinity/agent';
|
|
2
|
+
import type {IDL} from '@dfinity/candid';
|
|
3
|
+
import type {Principal} from '@dfinity/principal';
|
|
4
|
+
|
|
5
|
+
import {_SERVICE} from './mission_control.did';
|
|
6
|
+
|
|
7
|
+
export declare const idlFactory: IDL.InterfaceFactory;
|
|
8
|
+
export declare const canisterId: string;
|
|
9
|
+
|
|
10
|
+
export declare interface CreateActorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* @see {@link Agent}
|
|
13
|
+
*/
|
|
14
|
+
agent?: Agent;
|
|
15
|
+
/**
|
|
16
|
+
* @see {@link HttpAgentOptions}
|
|
17
|
+
*/
|
|
18
|
+
agentOptions?: HttpAgentOptions;
|
|
19
|
+
/**
|
|
20
|
+
* @see {@link ActorConfig}
|
|
21
|
+
*/
|
|
22
|
+
actorOptions?: ActorConfig;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
|
|
27
|
+
* @constructs {@link ActorSubClass}
|
|
28
|
+
* @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
|
|
29
|
+
* @param {CreateActorOptions} options - see {@link CreateActorOptions}
|
|
30
|
+
* @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
|
|
31
|
+
* @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
|
|
32
|
+
* @see {@link HttpAgentOptions}
|
|
33
|
+
* @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
|
|
34
|
+
* @see {@link ActorConfig}
|
|
35
|
+
*/
|
|
36
|
+
export declare const createActor: (
|
|
37
|
+
canisterId: string | Principal,
|
|
38
|
+
options?: CreateActorOptions
|
|
39
|
+
) => ActorSubclass<_SERVICE>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Intialized Actor using default settings, ready to talk to a canister using its candid interface
|
|
43
|
+
* @constructs {@link ActorSubClass}
|
|
44
|
+
*/
|
|
45
|
+
export declare const mission_control: ActorSubclass<_SERVICE>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Actor, HttpAgent} from '@dfinity/agent';
|
|
2
|
+
|
|
3
|
+
// Imports and re-exports candid interface
|
|
4
|
+
import {idlFactory} from './mission_control.did.js';
|
|
5
|
+
export {idlFactory} from './mission_control.did.js';
|
|
6
|
+
|
|
7
|
+
// CANISTER_ID is replaced by webpack based on node environment
|
|
8
|
+
|
|
9
|
+
export const createActor = (canisterId, options = {}) => {
|
|
10
|
+
const agent = options.agent || new HttpAgent({...options.agentOptions});
|
|
11
|
+
|
|
12
|
+
if (options.agent && options.agentOptions) {
|
|
13
|
+
console.warn(
|
|
14
|
+
'Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.'
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Fetch root key for certificate validation during development
|
|
19
|
+
if (process.env.DFX_NETWORK !== 'ic') {
|
|
20
|
+
agent.fetchRootKey().catch((err) => {
|
|
21
|
+
console.warn('Unable to fetch root key. Check to ensure that your local replica is running');
|
|
22
|
+
console.error(err);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Creates an actor with using the candid interface and the HttpAgent
|
|
27
|
+
return Actor.createActor(idlFactory, {
|
|
28
|
+
agent,
|
|
29
|
+
canisterId,
|
|
30
|
+
...options.actorOptions
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export interface Controller {
|
|
5
|
+
updated_at: bigint;
|
|
6
|
+
metadata: Array<[string, string]>;
|
|
7
|
+
created_at: bigint;
|
|
8
|
+
expires_at: [] | [bigint];
|
|
9
|
+
}
|
|
10
|
+
export interface Satellite {
|
|
11
|
+
updated_at: bigint;
|
|
12
|
+
metadata: Array<[string, string]>;
|
|
13
|
+
created_at: bigint;
|
|
14
|
+
satellite_id: Principal;
|
|
15
|
+
}
|
|
16
|
+
export interface SetController {
|
|
17
|
+
metadata: Array<[string, string]>;
|
|
18
|
+
expires_at: [] | [bigint];
|
|
19
|
+
}
|
|
20
|
+
export interface Tokens {
|
|
21
|
+
e8s: bigint;
|
|
22
|
+
}
|
|
23
|
+
export interface _SERVICE {
|
|
24
|
+
add_mission_control_controllers: ActorMethod<[Array<Principal>], undefined>;
|
|
25
|
+
add_satellites_controllers: ActorMethod<[Array<Principal>, Array<Principal>], undefined>;
|
|
26
|
+
create_satellite: ActorMethod<[string], Satellite>;
|
|
27
|
+
del_mission_control_controllers: ActorMethod<[Array<Principal>], undefined>;
|
|
28
|
+
del_satellites_controllers: ActorMethod<[Array<Principal>, Array<Principal>], undefined>;
|
|
29
|
+
get_user: ActorMethod<[], Principal>;
|
|
30
|
+
list_mission_control_controllers: ActorMethod<[], Array<[Principal, Controller]>>;
|
|
31
|
+
list_satellites: ActorMethod<[], Array<[Principal, Satellite]>>;
|
|
32
|
+
remove_mission_control_controllers: ActorMethod<[Array<Principal>], undefined>;
|
|
33
|
+
remove_satellites_controllers: ActorMethod<[Array<Principal>, Array<Principal>], undefined>;
|
|
34
|
+
set_mission_control_controllers: ActorMethod<[Array<Principal>, SetController], undefined>;
|
|
35
|
+
set_satellites_controllers: ActorMethod<
|
|
36
|
+
[Array<Principal>, Array<Principal>, SetController],
|
|
37
|
+
undefined
|
|
38
|
+
>;
|
|
39
|
+
top_up: ActorMethod<[Principal, Tokens], undefined>;
|
|
40
|
+
version: ActorMethod<[], string>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const idlFactory = ({IDL}) => {
|
|
2
|
+
const Satellite = IDL.Record({
|
|
3
|
+
updated_at: IDL.Nat64,
|
|
4
|
+
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
5
|
+
created_at: IDL.Nat64,
|
|
6
|
+
satellite_id: IDL.Principal
|
|
7
|
+
});
|
|
8
|
+
const Controller = IDL.Record({
|
|
9
|
+
updated_at: IDL.Nat64,
|
|
10
|
+
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
11
|
+
created_at: IDL.Nat64,
|
|
12
|
+
expires_at: IDL.Opt(IDL.Nat64)
|
|
13
|
+
});
|
|
14
|
+
const SetController = IDL.Record({
|
|
15
|
+
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
16
|
+
expires_at: IDL.Opt(IDL.Nat64)
|
|
17
|
+
});
|
|
18
|
+
const Tokens = IDL.Record({e8s: IDL.Nat64});
|
|
19
|
+
return IDL.Service({
|
|
20
|
+
add_mission_control_controllers: IDL.Func([IDL.Vec(IDL.Principal)], [], []),
|
|
21
|
+
add_satellites_controllers: IDL.Func([IDL.Vec(IDL.Principal), IDL.Vec(IDL.Principal)], [], []),
|
|
22
|
+
create_satellite: IDL.Func([IDL.Text], [Satellite], []),
|
|
23
|
+
del_mission_control_controllers: IDL.Func([IDL.Vec(IDL.Principal)], [], []),
|
|
24
|
+
del_satellites_controllers: IDL.Func([IDL.Vec(IDL.Principal), IDL.Vec(IDL.Principal)], [], []),
|
|
25
|
+
get_user: IDL.Func([], [IDL.Principal], ['query']),
|
|
26
|
+
list_mission_control_controllers: IDL.Func(
|
|
27
|
+
[],
|
|
28
|
+
[IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
|
|
29
|
+
['query']
|
|
30
|
+
),
|
|
31
|
+
list_satellites: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Principal, Satellite))], ['query']),
|
|
32
|
+
remove_mission_control_controllers: IDL.Func([IDL.Vec(IDL.Principal)], [], []),
|
|
33
|
+
remove_satellites_controllers: IDL.Func(
|
|
34
|
+
[IDL.Vec(IDL.Principal), IDL.Vec(IDL.Principal)],
|
|
35
|
+
[],
|
|
36
|
+
[]
|
|
37
|
+
),
|
|
38
|
+
set_mission_control_controllers: IDL.Func([IDL.Vec(IDL.Principal), SetController], [], []),
|
|
39
|
+
set_satellites_controllers: IDL.Func(
|
|
40
|
+
[IDL.Vec(IDL.Principal), IDL.Vec(IDL.Principal), SetController],
|
|
41
|
+
[],
|
|
42
|
+
[]
|
|
43
|
+
),
|
|
44
|
+
top_up: IDL.Func([IDL.Principal, Tokens], [], []),
|
|
45
|
+
version: IDL.Func([], [IDL.Text], ['query'])
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export const init = ({IDL}) => {
|
|
49
|
+
return [];
|
|
50
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {ActorConfig, ActorSubclass, Agent, HttpAgentOptions} from '@dfinity/agent';
|
|
2
|
+
import type {IDL} from '@dfinity/candid';
|
|
3
|
+
import type {Principal} from '@dfinity/principal';
|
|
4
|
+
|
|
5
|
+
import {_SERVICE} from './satellite.did';
|
|
6
|
+
|
|
7
|
+
export declare const idlFactory: IDL.InterfaceFactory;
|
|
8
|
+
export declare const canisterId: string;
|
|
9
|
+
|
|
10
|
+
export declare interface CreateActorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* @see {@link Agent}
|
|
13
|
+
*/
|
|
14
|
+
agent?: Agent;
|
|
15
|
+
/**
|
|
16
|
+
* @see {@link HttpAgentOptions}
|
|
17
|
+
*/
|
|
18
|
+
agentOptions?: HttpAgentOptions;
|
|
19
|
+
/**
|
|
20
|
+
* @see {@link ActorConfig}
|
|
21
|
+
*/
|
|
22
|
+
actorOptions?: ActorConfig;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
|
|
27
|
+
* @constructs {@link ActorSubClass}
|
|
28
|
+
* @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
|
|
29
|
+
* @param {CreateActorOptions} options - see {@link CreateActorOptions}
|
|
30
|
+
* @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
|
|
31
|
+
* @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
|
|
32
|
+
* @see {@link HttpAgentOptions}
|
|
33
|
+
* @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
|
|
34
|
+
* @see {@link ActorConfig}
|
|
35
|
+
*/
|
|
36
|
+
export declare const createActor: (
|
|
37
|
+
canisterId: string | Principal,
|
|
38
|
+
options?: CreateActorOptions
|
|
39
|
+
) => ActorSubclass<_SERVICE>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Intialized Actor using default settings, ready to talk to a canister using its candid interface
|
|
43
|
+
* @constructs {@link ActorSubClass}
|
|
44
|
+
*/
|
|
45
|
+
export declare const satellite: ActorSubclass<_SERVICE>;
|