@pbgtoken/rwa-contract 1.0.1 → 1.0.3
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/.env +3 -0
- package/dist/BSCAccountProvider.d.ts +3 -0
- package/dist/BinanceAccountProvider.d.ts +3 -0
- package/dist/BitcoinWalletProvider.d.ts +7 -0
- package/dist/CoinGeckoProvider.d.ts +2 -0
- package/dist/EthereumERC20AccountProvider.d.ts +3 -0
- package/dist/PricesProvider.d.ts +17 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +866 -3
- package/dist/validators/index.d.ts +374 -1
- package/jest.config.js +12 -0
- package/package.json +9 -2
- package/tests/BSCAccountProvider.test.ts +25 -0
- package/tests/BinanceAccountProvider.test.ts +26 -0
- package/tests/BitcoinWalletProvider.test.ts +28 -0
- package/tests/EthereumERC20AccountProvider.test.ts +25 -0
- package/tests/const.ts +16 -0
|
@@ -5,7 +5,7 @@ import type { UplcData, UplcProgram } from "@helios-lang/uplc";
|
|
|
5
5
|
export declare const tokenized_account: {
|
|
6
6
|
$name: "tokenized_account";
|
|
7
7
|
$purpose: "mixed";
|
|
8
|
-
$currentScriptIndex:
|
|
8
|
+
$currentScriptIndex: 1;
|
|
9
9
|
$sourceCode: string;
|
|
10
10
|
$dependencies: readonly [];
|
|
11
11
|
$hashDependencies: never[];
|
|
@@ -201,3 +201,376 @@ export declare const tokenized_account: {
|
|
|
201
201
|
}, void>;
|
|
202
202
|
};
|
|
203
203
|
};
|
|
204
|
+
export declare const one_to_one_asset: {
|
|
205
|
+
$name: "one_to_one_asset";
|
|
206
|
+
$purpose: "mixed";
|
|
207
|
+
$currentScriptIndex: 0;
|
|
208
|
+
$sourceCode: string;
|
|
209
|
+
$dependencies: readonly [];
|
|
210
|
+
$hashDependencies: {
|
|
211
|
+
$name: "tokenized_account";
|
|
212
|
+
$purpose: "mixed";
|
|
213
|
+
$currentScriptIndex: 1;
|
|
214
|
+
$sourceCode: string;
|
|
215
|
+
$dependencies: readonly [];
|
|
216
|
+
$hashDependencies: never[];
|
|
217
|
+
$dependsOnOwnHash: boolean;
|
|
218
|
+
$Redeemer: (config: CastConfig) => Cast<{
|
|
219
|
+
Other: {
|
|
220
|
+
redeemer: UplcData;
|
|
221
|
+
};
|
|
222
|
+
} | {
|
|
223
|
+
Spending: {
|
|
224
|
+
redeemer: UplcData;
|
|
225
|
+
};
|
|
226
|
+
}, {
|
|
227
|
+
Other: {
|
|
228
|
+
redeemer: UplcData;
|
|
229
|
+
};
|
|
230
|
+
} | {
|
|
231
|
+
Spending: {
|
|
232
|
+
redeemer: UplcData;
|
|
233
|
+
};
|
|
234
|
+
}>;
|
|
235
|
+
$Datum: (config: CastConfig) => Cast<UplcData, UplcData>;
|
|
236
|
+
$types: {
|
|
237
|
+
State: (config: CastConfig) => Cast<{
|
|
238
|
+
current_supply: bigint;
|
|
239
|
+
supply_after_last_mint: bigint;
|
|
240
|
+
transfer_id_before_last_mint: number[];
|
|
241
|
+
type: string;
|
|
242
|
+
account: number[];
|
|
243
|
+
name: string;
|
|
244
|
+
description: string;
|
|
245
|
+
decimals: bigint;
|
|
246
|
+
ticker: string;
|
|
247
|
+
url: string;
|
|
248
|
+
logo: string;
|
|
249
|
+
}, {
|
|
250
|
+
current_supply: IntLike;
|
|
251
|
+
supply_after_last_mint: IntLike;
|
|
252
|
+
transfer_id_before_last_mint: number[];
|
|
253
|
+
type: string;
|
|
254
|
+
account: number[];
|
|
255
|
+
name: string;
|
|
256
|
+
description: string;
|
|
257
|
+
decimals: IntLike;
|
|
258
|
+
ticker: string;
|
|
259
|
+
url: string;
|
|
260
|
+
logo: string;
|
|
261
|
+
}>;
|
|
262
|
+
Cip68Extra: (config: CastConfig) => Cast<{
|
|
263
|
+
Unused: {};
|
|
264
|
+
}, {
|
|
265
|
+
Unused: {};
|
|
266
|
+
}>;
|
|
267
|
+
Metadata: (config: CastConfig) => Cast<{
|
|
268
|
+
Cip68: {
|
|
269
|
+
state: {
|
|
270
|
+
current_supply: bigint;
|
|
271
|
+
supply_after_last_mint: bigint;
|
|
272
|
+
transfer_id_before_last_mint: number[];
|
|
273
|
+
type: string;
|
|
274
|
+
account: number[];
|
|
275
|
+
name: string;
|
|
276
|
+
description: string;
|
|
277
|
+
decimals: bigint;
|
|
278
|
+
ticker: string;
|
|
279
|
+
url: string;
|
|
280
|
+
logo: string;
|
|
281
|
+
};
|
|
282
|
+
version: bigint;
|
|
283
|
+
extra: {
|
|
284
|
+
Unused: {};
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
}, {
|
|
288
|
+
Cip68: {
|
|
289
|
+
state: {
|
|
290
|
+
current_supply: IntLike;
|
|
291
|
+
supply_after_last_mint: IntLike;
|
|
292
|
+
transfer_id_before_last_mint: number[];
|
|
293
|
+
type: string;
|
|
294
|
+
account: number[];
|
|
295
|
+
name: string;
|
|
296
|
+
description: string;
|
|
297
|
+
decimals: IntLike;
|
|
298
|
+
ticker: string;
|
|
299
|
+
url: string;
|
|
300
|
+
logo: string;
|
|
301
|
+
};
|
|
302
|
+
version: IntLike;
|
|
303
|
+
extra: {
|
|
304
|
+
Unused: {};
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
}>;
|
|
308
|
+
Redeemer: (config: CastConfig) => Cast<{
|
|
309
|
+
total_reserves: number;
|
|
310
|
+
reserves_change: number;
|
|
311
|
+
latest_transfer_id: number[];
|
|
312
|
+
}, {
|
|
313
|
+
total_reserves: number;
|
|
314
|
+
reserves_change: number;
|
|
315
|
+
latest_transfer_id: number[];
|
|
316
|
+
}>;
|
|
317
|
+
};
|
|
318
|
+
$functions: {
|
|
319
|
+
"Metadata::state": (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
320
|
+
self: {
|
|
321
|
+
Cip68: {
|
|
322
|
+
state: {
|
|
323
|
+
current_supply: IntLike;
|
|
324
|
+
supply_after_last_mint: IntLike;
|
|
325
|
+
transfer_id_before_last_mint: number[];
|
|
326
|
+
type: string;
|
|
327
|
+
account: number[];
|
|
328
|
+
name: string;
|
|
329
|
+
description: string;
|
|
330
|
+
decimals: IntLike;
|
|
331
|
+
ticker: string;
|
|
332
|
+
url: string;
|
|
333
|
+
logo: string;
|
|
334
|
+
};
|
|
335
|
+
version: IntLike;
|
|
336
|
+
extra: {
|
|
337
|
+
Unused: {};
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
}, {
|
|
342
|
+
current_supply: bigint;
|
|
343
|
+
supply_after_last_mint: bigint;
|
|
344
|
+
transfer_id_before_last_mint: number[];
|
|
345
|
+
type: string;
|
|
346
|
+
account: number[];
|
|
347
|
+
name: string;
|
|
348
|
+
description: string;
|
|
349
|
+
decimals: bigint;
|
|
350
|
+
ticker: string;
|
|
351
|
+
url: string;
|
|
352
|
+
logo: string;
|
|
353
|
+
}>;
|
|
354
|
+
SEED_ID: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, TxOutputId>;
|
|
355
|
+
ORACLE_KEYS: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, PubKeyHash[]>;
|
|
356
|
+
INITIAL_PRICE: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number>;
|
|
357
|
+
TYPE: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
358
|
+
ACCOUNT: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number[]>;
|
|
359
|
+
TICKER: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
360
|
+
NAME: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
361
|
+
DESCRIPTION: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
362
|
+
DECIMALS: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, bigint>;
|
|
363
|
+
URL: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
364
|
+
LOGO: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
365
|
+
ticker_bytes: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number[]>;
|
|
366
|
+
user_token_name: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number[]>;
|
|
367
|
+
ref_token_name: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number[]>;
|
|
368
|
+
own_hash: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, ScriptHash>;
|
|
369
|
+
own_mph: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, MintingPolicyHash>;
|
|
370
|
+
own_address: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, Address>;
|
|
371
|
+
ref_token_asset_class: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, AssetClass>;
|
|
372
|
+
user_token_asset_class: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, AssetClass>;
|
|
373
|
+
validate_initialization: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
374
|
+
$scriptContext: UplcData;
|
|
375
|
+
}, void>;
|
|
376
|
+
signed_by_quorum: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
377
|
+
$scriptContext: UplcData;
|
|
378
|
+
}, boolean>;
|
|
379
|
+
calc_token_price: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
380
|
+
R: number;
|
|
381
|
+
Delta: number;
|
|
382
|
+
current_supply: IntLike;
|
|
383
|
+
supply_after_last_mint: IntLike;
|
|
384
|
+
}, number>;
|
|
385
|
+
validate_state_change: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
386
|
+
$scriptContext: UplcData;
|
|
387
|
+
redeemer: {
|
|
388
|
+
total_reserves: number;
|
|
389
|
+
reserves_change: number;
|
|
390
|
+
latest_transfer_id: number[];
|
|
391
|
+
};
|
|
392
|
+
input: TxInput;
|
|
393
|
+
}, void>;
|
|
394
|
+
main: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
395
|
+
$scriptContext: UplcData;
|
|
396
|
+
$datum?: UplcData;
|
|
397
|
+
args: {
|
|
398
|
+
Other: {
|
|
399
|
+
redeemer: UplcData;
|
|
400
|
+
};
|
|
401
|
+
} | {
|
|
402
|
+
Spending: {
|
|
403
|
+
redeemer: UplcData;
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
}, void>;
|
|
407
|
+
};
|
|
408
|
+
}[];
|
|
409
|
+
$dependsOnOwnHash: boolean;
|
|
410
|
+
$Redeemer: (config: CastConfig) => Cast<{
|
|
411
|
+
Other: {
|
|
412
|
+
redeemer: UplcData;
|
|
413
|
+
};
|
|
414
|
+
} | {
|
|
415
|
+
Spending: {
|
|
416
|
+
redeemer: UplcData;
|
|
417
|
+
};
|
|
418
|
+
}, {
|
|
419
|
+
Other: {
|
|
420
|
+
redeemer: UplcData;
|
|
421
|
+
};
|
|
422
|
+
} | {
|
|
423
|
+
Spending: {
|
|
424
|
+
redeemer: UplcData;
|
|
425
|
+
};
|
|
426
|
+
}>;
|
|
427
|
+
$Datum: (config: CastConfig) => Cast<UplcData, UplcData>;
|
|
428
|
+
$types: {
|
|
429
|
+
State: (config: CastConfig) => Cast<{
|
|
430
|
+
supply: bigint;
|
|
431
|
+
type: string;
|
|
432
|
+
account: number[];
|
|
433
|
+
name: string;
|
|
434
|
+
description: string;
|
|
435
|
+
decimals: bigint;
|
|
436
|
+
ticker: string;
|
|
437
|
+
url: string;
|
|
438
|
+
logo: string;
|
|
439
|
+
}, {
|
|
440
|
+
supply: IntLike;
|
|
441
|
+
type: string;
|
|
442
|
+
account: number[];
|
|
443
|
+
name: string;
|
|
444
|
+
description: string;
|
|
445
|
+
decimals: IntLike;
|
|
446
|
+
ticker: string;
|
|
447
|
+
url: string;
|
|
448
|
+
logo: string;
|
|
449
|
+
}>;
|
|
450
|
+
Cip68Extra: (config: CastConfig) => Cast<{
|
|
451
|
+
Unused: {};
|
|
452
|
+
}, {
|
|
453
|
+
Unused: {};
|
|
454
|
+
}>;
|
|
455
|
+
Metadata: (config: CastConfig) => Cast<{
|
|
456
|
+
Cip68: {
|
|
457
|
+
state: {
|
|
458
|
+
supply: bigint;
|
|
459
|
+
type: string;
|
|
460
|
+
account: number[];
|
|
461
|
+
name: string;
|
|
462
|
+
description: string;
|
|
463
|
+
decimals: bigint;
|
|
464
|
+
ticker: string;
|
|
465
|
+
url: string;
|
|
466
|
+
logo: string;
|
|
467
|
+
};
|
|
468
|
+
version: bigint;
|
|
469
|
+
extra: {
|
|
470
|
+
Unused: {};
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
}, {
|
|
474
|
+
Cip68: {
|
|
475
|
+
state: {
|
|
476
|
+
supply: IntLike;
|
|
477
|
+
type: string;
|
|
478
|
+
account: number[];
|
|
479
|
+
name: string;
|
|
480
|
+
description: string;
|
|
481
|
+
decimals: IntLike;
|
|
482
|
+
ticker: string;
|
|
483
|
+
url: string;
|
|
484
|
+
logo: string;
|
|
485
|
+
};
|
|
486
|
+
version: IntLike;
|
|
487
|
+
extra: {
|
|
488
|
+
Unused: {};
|
|
489
|
+
};
|
|
490
|
+
};
|
|
491
|
+
}>;
|
|
492
|
+
Redeemer: (config: CastConfig) => Cast<{
|
|
493
|
+
reserves: bigint;
|
|
494
|
+
}, {
|
|
495
|
+
reserves: IntLike;
|
|
496
|
+
}>;
|
|
497
|
+
};
|
|
498
|
+
$functions: {
|
|
499
|
+
"Metadata::state": (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
500
|
+
self: {
|
|
501
|
+
Cip68: {
|
|
502
|
+
state: {
|
|
503
|
+
supply: IntLike;
|
|
504
|
+
type: string;
|
|
505
|
+
account: number[];
|
|
506
|
+
name: string;
|
|
507
|
+
description: string;
|
|
508
|
+
decimals: IntLike;
|
|
509
|
+
ticker: string;
|
|
510
|
+
url: string;
|
|
511
|
+
logo: string;
|
|
512
|
+
};
|
|
513
|
+
version: IntLike;
|
|
514
|
+
extra: {
|
|
515
|
+
Unused: {};
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
};
|
|
519
|
+
}, {
|
|
520
|
+
supply: bigint;
|
|
521
|
+
type: string;
|
|
522
|
+
account: number[];
|
|
523
|
+
name: string;
|
|
524
|
+
description: string;
|
|
525
|
+
decimals: bigint;
|
|
526
|
+
ticker: string;
|
|
527
|
+
url: string;
|
|
528
|
+
logo: string;
|
|
529
|
+
}>;
|
|
530
|
+
SEED_ID: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, TxOutputId>;
|
|
531
|
+
ORACLE_KEYS: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, PubKeyHash[]>;
|
|
532
|
+
INITIAL_PRICE: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number>;
|
|
533
|
+
TYPE: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
534
|
+
ACCOUNT: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number[]>;
|
|
535
|
+
TICKER: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
536
|
+
NAME: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
537
|
+
DESCRIPTION: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
538
|
+
DECIMALS: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, bigint>;
|
|
539
|
+
URL: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
540
|
+
LOGO: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, string>;
|
|
541
|
+
ticker_bytes: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number[]>;
|
|
542
|
+
user_token_name: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number[]>;
|
|
543
|
+
ref_token_name: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, number[]>;
|
|
544
|
+
own_hash: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, ScriptHash>;
|
|
545
|
+
own_mph: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, MintingPolicyHash>;
|
|
546
|
+
own_address: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, Address>;
|
|
547
|
+
ref_token_asset_class: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, AssetClass>;
|
|
548
|
+
user_token_asset_class: (uplc: UplcProgram, config: CastConfig) => UserFunc<{}, AssetClass>;
|
|
549
|
+
validate_initialization: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
550
|
+
$scriptContext: UplcData;
|
|
551
|
+
}, void>;
|
|
552
|
+
signed_by_quorum: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
553
|
+
$scriptContext: UplcData;
|
|
554
|
+
}, boolean>;
|
|
555
|
+
validate_state_change: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
556
|
+
$scriptContext: UplcData;
|
|
557
|
+
redeemer: {
|
|
558
|
+
reserves: IntLike;
|
|
559
|
+
};
|
|
560
|
+
input: TxInput;
|
|
561
|
+
}, void>;
|
|
562
|
+
main: (uplc: UplcProgram, config: CastConfig) => UserFunc<{
|
|
563
|
+
$scriptContext: UplcData;
|
|
564
|
+
$datum?: UplcData;
|
|
565
|
+
args: {
|
|
566
|
+
Other: {
|
|
567
|
+
redeemer: UplcData;
|
|
568
|
+
};
|
|
569
|
+
} | {
|
|
570
|
+
Spending: {
|
|
571
|
+
redeemer: UplcData;
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
}, void>;
|
|
575
|
+
};
|
|
576
|
+
};
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { createDefaultPreset } = require("ts-jest");
|
|
2
|
+
|
|
3
|
+
const tsJestTransformCfg = createDefaultPreset().transform;
|
|
4
|
+
|
|
5
|
+
/** @type {import("jest").Config} **/
|
|
6
|
+
module.exports = {
|
|
7
|
+
testEnvironment: "node",
|
|
8
|
+
transform: {
|
|
9
|
+
...tsJestTransformCfg,
|
|
10
|
+
},
|
|
11
|
+
testMatch: ["**/tests/**/*.test.ts"],
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbgtoken/rwa-contract",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
6
|
"type": "module",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"license": "AGPL-version-3.0",
|
|
9
9
|
"private": false,
|
|
10
10
|
"engines": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"url": "https://github.com/christianschmitz"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
+
"test": "jest",
|
|
27
28
|
"build": "npm run build:validators && npm run build:types && npm run build:bundle",
|
|
28
29
|
"build:bundle": "node ./esbuild.js",
|
|
29
30
|
"build:types": "npx tsc --declaration --emitDeclarationOnly",
|
|
@@ -37,6 +38,12 @@
|
|
|
37
38
|
"@helios-lang/tx-utils": "^0.6.13",
|
|
38
39
|
"@helios-lang/type-utils": "^0.3.0",
|
|
39
40
|
"esbuild": "^0.25.4",
|
|
41
|
+
"ethers": "^6.14.1",
|
|
40
42
|
"typescript": "^5.8.3"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/jest": "^29.5.14",
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"ts-jest": "^29.3.4"
|
|
41
48
|
}
|
|
42
49
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { makeBSCAccountProvider } from "../src/BSCAccountProvider";
|
|
2
|
+
import { makeCoinGeckoProvider } from "../src/CoinGeckoProvider";
|
|
3
|
+
import { TEST_DATA } from "./const";
|
|
4
|
+
|
|
5
|
+
const priceProvider = makeCoinGeckoProvider();
|
|
6
|
+
|
|
7
|
+
describe("BSCAccountProvider", () => {
|
|
8
|
+
const provider = makeBSCAccountProvider(TEST_DATA.bnbAddress, priceProvider, TEST_DATA.alchemyApiKey);
|
|
9
|
+
|
|
10
|
+
test("should return balance as a number", async () => {
|
|
11
|
+
const balance = await provider.balance;
|
|
12
|
+
expect(typeof balance).toBe("number");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("should return transfer history as array", async () => {
|
|
16
|
+
const transfers = await provider.transferHistory;
|
|
17
|
+
expect(Array.isArray(transfers)).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("should calculate deposits in USD from transfer IDs", async () => {
|
|
21
|
+
const transfers = await provider.transferHistory;
|
|
22
|
+
const depositUsd = await provider.deposits(transfers);
|
|
23
|
+
expect(typeof depositUsd).toBe("number");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { makeBinanceAccountProvider } from "../src/BinanceAccountProvider";
|
|
2
|
+
import { makeCoinGeckoProvider } from "../src/CoinGeckoProvider";
|
|
3
|
+
import { TEST_DATA } from "./const";
|
|
4
|
+
|
|
5
|
+
const priceProvider = makeCoinGeckoProvider();
|
|
6
|
+
|
|
7
|
+
describe("BinanceAccountProvider", () => {
|
|
8
|
+
const provider = makeBinanceAccountProvider(TEST_DATA.binanceApiKey, priceProvider);
|
|
9
|
+
|
|
10
|
+
test("should return a USD balance", async () => {
|
|
11
|
+
const usdBalance = await provider.balance;
|
|
12
|
+
expect(typeof usdBalance).toBe("number");
|
|
13
|
+
expect(usdBalance).toBeGreaterThanOrEqual(0);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("should return an array of transfer history", async () => {
|
|
17
|
+
const transfers = await provider.transferHistory;
|
|
18
|
+
expect(Array.isArray(transfers)).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("should calculate deposits in USD from transfer IDs", async () => {
|
|
22
|
+
const transfers = await provider.transferHistory;
|
|
23
|
+
const depositUsd = await provider.deposits(transfers);
|
|
24
|
+
expect(typeof depositUsd).toBe("number");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { makeBitcoinWalletProvider } from "../src/BitcoinWalletProvider";
|
|
2
|
+
import { makeCoinGeckoProvider } from "../src/CoinGeckoProvider";
|
|
3
|
+
import { TEST_DATA } from "./const";
|
|
4
|
+
|
|
5
|
+
const priceProvider = makeCoinGeckoProvider();
|
|
6
|
+
|
|
7
|
+
describe("BitcoinWalletProvider", () => {
|
|
8
|
+
const provider = makeBitcoinWalletProvider(TEST_DATA.btcAddress, priceProvider);
|
|
9
|
+
|
|
10
|
+
test("should return a valid Sats balance", async () => {
|
|
11
|
+
const sats = await provider.getSats();
|
|
12
|
+
expect(typeof sats).toBe("number");
|
|
13
|
+
console.log(sats)
|
|
14
|
+
expect(sats).toBeGreaterThanOrEqual(0);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("should return an array for transfer history", async () => {
|
|
18
|
+
const transfers = await provider.transferHistory;
|
|
19
|
+
console.log(transfers)
|
|
20
|
+
expect(Array.isArray(transfers)).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("should calculate USD deposits correctly", async () => {
|
|
24
|
+
const transfers = await provider.transferHistory;
|
|
25
|
+
const deposits = await provider.deposits(transfers);
|
|
26
|
+
expect(typeof deposits).toBe("number");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { makeEthereumERC20AccountProvider } from "../src/EthereumERC20AccountProvider";
|
|
2
|
+
import { makeCoinGeckoProvider } from "../src/CoinGeckoProvider";
|
|
3
|
+
import { TEST_DATA } from "./const";
|
|
4
|
+
|
|
5
|
+
const priceProvider = makeCoinGeckoProvider();
|
|
6
|
+
|
|
7
|
+
describe("EthereumERC20AccountProvider", () => {
|
|
8
|
+
const provider = makeEthereumERC20AccountProvider(TEST_DATA.ethAddress, priceProvider, TEST_DATA.alchemyApiKey, TEST_DATA.usdtContract);
|
|
9
|
+
|
|
10
|
+
test("should return balance as a number", async () => {
|
|
11
|
+
const balance = await provider.balance;
|
|
12
|
+
expect(typeof balance).toBe("number");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("should return transfer history as array", async () => {
|
|
16
|
+
const transfers = await provider.transferHistory;
|
|
17
|
+
expect(Array.isArray(transfers)).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("should calculate deposits in USD from transfer IDs", async () => {
|
|
21
|
+
const transfers = await provider.transferHistory;
|
|
22
|
+
const depositUsd = await provider.deposits(transfers);
|
|
23
|
+
expect(typeof depositUsd).toBe("number");
|
|
24
|
+
});
|
|
25
|
+
});
|
package/tests/const.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const TEST_DATA = {
|
|
2
|
+
// Ethereum ERC-20
|
|
3
|
+
ethAddress: "0xd31F13827c798d8f457313C2A7bA5f764e4842D8",
|
|
4
|
+
usdtContract: "0xdAC17F958D2ee523a2206206994597C13D831ec7" as `0x${string}`, // USDT contract on Ethereum
|
|
5
|
+
infuraRpc: process.env.INFURA_RPC_URL || "https://1rpc.io/eth",
|
|
6
|
+
alchemyApiKey: process.env.ALCHEMY_API_KEY || "",
|
|
7
|
+
|
|
8
|
+
// Binance Smart Chain
|
|
9
|
+
bnbAddress: "0xd31f13827c798d8f457313c2a7ba5f764e4842d8",
|
|
10
|
+
|
|
11
|
+
// Bitcoin
|
|
12
|
+
btcAddress: "bc1q23ztqjmh9a32z8j4rstg035y3c3vpfe0la3nck",
|
|
13
|
+
|
|
14
|
+
// Binance Account API
|
|
15
|
+
binanceApiKey: process.env.BINANCE_API_KEY || "",
|
|
16
|
+
}
|