ic-mops 0.13.1 → 0.14.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/cli.js CHANGED
@@ -3,12 +3,13 @@
3
3
  import fs from 'fs';
4
4
  import {program} from 'commander';
5
5
  import chalk from 'chalk';
6
+ import {Principal} from '@dfinity/principal';
6
7
 
7
8
  import {init} from './commands/init.js';
8
9
  import {publish} from './commands/publish.js';
9
10
  import {importPem} from './commands/import-identity.js';
10
11
  import {sources} from './commands/sources.js';
11
- import {checkApiCompatibility, getNetwork, setNetwork, apiVersion, checkConfigFile} from './mops.js';
12
+ import {checkApiCompatibility, getNetwork, setNetwork, apiVersion, checkConfigFile, mainActor} from './mops.js';
12
13
  import {whoami} from './commands/whoami.js';
13
14
  import {installAll} from './commands/install-all.js';
14
15
  import {search} from './commands/search.js';
@@ -246,4 +247,36 @@ program
246
247
  }
247
248
  });
248
249
 
250
+ // airdrop
251
+ program
252
+ .command('airdrop <check|claim> [canister]')
253
+ .action(async (sub, canister) => {
254
+ let main = await mainActor(true);
255
+ if (sub === 'check') {
256
+ let amount = await main.getAirdropAmount();
257
+ if (amount === 0n) {
258
+ console.log('No airdrop available');
259
+ return;
260
+ }
261
+ console.log(`You can claim ${Number(amount) / 1_000_000_000_000} TCycles`);
262
+ }
263
+ else if (sub === 'claim') {
264
+ let principal;
265
+ try {
266
+ principal = Principal.fromText(canister);
267
+ }
268
+ catch (err) {
269
+ console.log('Invalid canister id');
270
+ console.log(err);
271
+ return;
272
+ }
273
+ console.log('Sending cycles to the canister ' + canister);
274
+ let res = await main.claimAirdrop(principal);
275
+ console.log(res);
276
+ }
277
+ else {
278
+ console.log('Unknown sub command. Available sub commands: check, claim');
279
+ }
280
+ });
281
+
249
282
  program.parse();
@@ -180,7 +180,10 @@ type DependencyV2 =
180
180
  version: text;
181
181
  };
182
182
  service : {
183
+ claimAirdrop: (principal) -> (text);
183
184
  finishPublish: (PublishingId) -> (Result);
185
+ getAirdropAmount: () -> (nat) query;
186
+ getAirdropAmountAll: () -> (nat) query;
184
187
  getApiVersion: () -> (Text) query;
185
188
  getDefaultPackages: (text) -> (vec record {
186
189
  PackageName__1;
@@ -208,5 +211,6 @@ service : {
208
211
  setUserProp: (text, text) -> (Result_3);
209
212
  startFileUpload: (PublishingId, Text, nat, blob) -> (Result_2);
210
213
  startPublish: (PackageConfigV2) -> (Result_1);
214
+ takeAirdropSnapshot: () -> () oneway;
211
215
  uploadFileChunk: (PublishingId, FileId, nat, blob) -> (Result);
212
216
  }
@@ -146,7 +146,10 @@ export interface User__1 {
146
146
  export type Ver = string;
147
147
  export type Version = string;
148
148
  export interface _SERVICE {
149
+ 'claimAirdrop' : ActorMethod<[Principal], string>,
149
150
  'finishPublish' : ActorMethod<[PublishingId], Result>,
151
+ 'getAirdropAmount' : ActorMethod<[], bigint>,
152
+ 'getAirdropAmountAll' : ActorMethod<[], bigint>,
150
153
  'getApiVersion' : ActorMethod<[], Text>,
151
154
  'getDefaultPackages' : ActorMethod<
152
155
  [string],
@@ -178,6 +181,7 @@ export interface _SERVICE {
178
181
  Result_2
179
182
  >,
180
183
  'startPublish' : ActorMethod<[PackageConfigV2], Result_1>,
184
+ 'takeAirdropSnapshot' : ActorMethod<[], undefined>,
181
185
  'uploadFileChunk' : ActorMethod<
182
186
  [PublishingId, FileId, bigint, Uint8Array | number[]],
183
187
  Result
@@ -137,7 +137,10 @@ export const idlFactory = ({ IDL }) => {
137
137
  const PublishingErr = IDL.Text;
138
138
  const Result_1 = IDL.Variant({ 'ok' : PublishingId, 'err' : PublishingErr });
139
139
  return IDL.Service({
140
+ 'claimAirdrop' : IDL.Func([IDL.Principal], [IDL.Text], []),
140
141
  'finishPublish' : IDL.Func([PublishingId], [Result], []),
142
+ 'getAirdropAmount' : IDL.Func([], [IDL.Nat], ['query']),
143
+ 'getAirdropAmountAll' : IDL.Func([], [IDL.Nat], ['query']),
141
144
  'getApiVersion' : IDL.Func([], [Text], ['query']),
142
145
  'getDefaultPackages' : IDL.Func(
143
146
  [IDL.Text],
@@ -193,6 +196,7 @@ export const idlFactory = ({ IDL }) => {
193
196
  [],
194
197
  ),
195
198
  'startPublish' : IDL.Func([PackageConfigV2], [Result_1], []),
199
+ 'takeAirdropSnapshot' : IDL.Func([], [], ['oneway']),
196
200
  'uploadFileChunk' : IDL.Func(
197
201
  [PublishingId, FileId, IDL.Nat, IDL.Vec(IDL.Nat8)],
198
202
  [Result],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "cli.js"