@zebec-network/exchange-card-sdk 1.1.0 → 1.1.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/README.md +339 -339
- package/dist/artifacts/typechain-types/ERC20.d.ts +7 -40
- package/dist/artifacts/typechain-types/ZebecCard.d.ts +21 -103
- package/dist/artifacts/typechain-types/common.d.ts +1 -5
- package/dist/artifacts/typechain-types/index.js +17 -7
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +5 -1
- package/dist/helpers/apiHelpers.d.ts +1 -1
- package/dist/helpers/apiHelpers.js +2 -2
- package/dist/services/TaoService.js +1 -1
- package/dist/services/TonService.d.ts +1 -1
- package/dist/services/TonService.js +1 -1
- package/dist/services/XdbService.d.ts +11 -17
- package/dist/services/XdbService.js +38 -56
- package/dist/services/stellarService.d.ts +1 -1
- package/dist/services/stellarService.js +8 -5
- package/package.json +1 -1
|
@@ -27,11 +27,7 @@ export interface ERC20Interface extends Interface {
|
|
|
27
27
|
decodeFunctionResult(functionFragment: "transferFrom", data: BytesLike): Result;
|
|
28
28
|
}
|
|
29
29
|
export declare namespace ApprovalEvent {
|
|
30
|
-
type InputTuple = [
|
|
31
|
-
owner: AddressLike,
|
|
32
|
-
spender: AddressLike,
|
|
33
|
-
value: BigNumberish
|
|
34
|
-
];
|
|
30
|
+
type InputTuple = [owner: AddressLike, spender: AddressLike, value: BigNumberish];
|
|
35
31
|
type OutputTuple = [owner: string, spender: string, value: bigint];
|
|
36
32
|
interface OutputObject {
|
|
37
33
|
owner: string;
|
|
@@ -44,11 +40,7 @@ export declare namespace ApprovalEvent {
|
|
|
44
40
|
type LogDescription = TypedLogDescription<Event>;
|
|
45
41
|
}
|
|
46
42
|
export declare namespace TransferEvent {
|
|
47
|
-
type InputTuple = [
|
|
48
|
-
from: AddressLike,
|
|
49
|
-
to: AddressLike,
|
|
50
|
-
value: BigNumberish
|
|
51
|
-
];
|
|
43
|
+
type InputTuple = [from: AddressLike, to: AddressLike, value: BigNumberish];
|
|
52
44
|
type OutputTuple = [from: string, to: string, value: bigint];
|
|
53
45
|
interface OutputObject {
|
|
54
46
|
from: string;
|
|
@@ -73,12 +65,7 @@ export interface ERC20 extends BaseContract {
|
|
|
73
65
|
listeners<TCEvent extends TypedContractEvent>(event: TCEvent): Promise<Array<TypedListener<TCEvent>>>;
|
|
74
66
|
listeners(eventName?: string): Promise<Array<Listener>>;
|
|
75
67
|
removeAllListeners<TCEvent extends TypedContractEvent>(event?: TCEvent): Promise<this>;
|
|
76
|
-
allowance: TypedContractMethod<[
|
|
77
|
-
owner: AddressLike,
|
|
78
|
-
spender: AddressLike
|
|
79
|
-
], [
|
|
80
|
-
bigint
|
|
81
|
-
], "view">;
|
|
68
|
+
allowance: TypedContractMethod<[owner: AddressLike, spender: AddressLike], [bigint], "view">;
|
|
82
69
|
approve: TypedContractMethod<[
|
|
83
70
|
spender: AddressLike,
|
|
84
71
|
value: BigNumberish
|
|
@@ -92,12 +79,7 @@ export interface ERC20 extends BaseContract {
|
|
|
92
79
|
started: TypedContractMethod<[], [boolean], "view">;
|
|
93
80
|
symbol: TypedContractMethod<[], [string], "view">;
|
|
94
81
|
totalSupply: TypedContractMethod<[], [bigint], "view">;
|
|
95
|
-
transfer: TypedContractMethod<[
|
|
96
|
-
to: AddressLike,
|
|
97
|
-
value: BigNumberish
|
|
98
|
-
], [
|
|
99
|
-
boolean
|
|
100
|
-
], "nonpayable">;
|
|
82
|
+
transfer: TypedContractMethod<[to: AddressLike, value: BigNumberish], [boolean], "nonpayable">;
|
|
101
83
|
transferFrom: TypedContractMethod<[
|
|
102
84
|
from: AddressLike,
|
|
103
85
|
to: AddressLike,
|
|
@@ -106,18 +88,8 @@ export interface ERC20 extends BaseContract {
|
|
|
106
88
|
boolean
|
|
107
89
|
], "nonpayable">;
|
|
108
90
|
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
|
|
109
|
-
getFunction(nameOrSignature: "allowance"): TypedContractMethod<[
|
|
110
|
-
|
|
111
|
-
spender: AddressLike
|
|
112
|
-
], [
|
|
113
|
-
bigint
|
|
114
|
-
], "view">;
|
|
115
|
-
getFunction(nameOrSignature: "approve"): TypedContractMethod<[
|
|
116
|
-
spender: AddressLike,
|
|
117
|
-
value: BigNumberish
|
|
118
|
-
], [
|
|
119
|
-
boolean
|
|
120
|
-
], "nonpayable">;
|
|
91
|
+
getFunction(nameOrSignature: "allowance"): TypedContractMethod<[owner: AddressLike, spender: AddressLike], [bigint], "view">;
|
|
92
|
+
getFunction(nameOrSignature: "approve"): TypedContractMethod<[spender: AddressLike, value: BigNumberish], [boolean], "nonpayable">;
|
|
121
93
|
getFunction(nameOrSignature: "balanceOf"): TypedContractMethod<[account: AddressLike], [bigint], "view">;
|
|
122
94
|
getFunction(nameOrSignature: "decimals"): TypedContractMethod<[], [bigint], "view">;
|
|
123
95
|
getFunction(nameOrSignature: "minter"): TypedContractMethod<[], [string], "view">;
|
|
@@ -125,12 +97,7 @@ export interface ERC20 extends BaseContract {
|
|
|
125
97
|
getFunction(nameOrSignature: "started"): TypedContractMethod<[], [boolean], "view">;
|
|
126
98
|
getFunction(nameOrSignature: "symbol"): TypedContractMethod<[], [string], "view">;
|
|
127
99
|
getFunction(nameOrSignature: "totalSupply"): TypedContractMethod<[], [bigint], "view">;
|
|
128
|
-
getFunction(nameOrSignature: "transfer"): TypedContractMethod<[
|
|
129
|
-
to: AddressLike,
|
|
130
|
-
value: BigNumberish
|
|
131
|
-
], [
|
|
132
|
-
boolean
|
|
133
|
-
], "nonpayable">;
|
|
100
|
+
getFunction(nameOrSignature: "transfer"): TypedContractMethod<[to: AddressLike, value: BigNumberish], [boolean], "nonpayable">;
|
|
134
101
|
getFunction(nameOrSignature: "transferFrom"): TypedContractMethod<[
|
|
135
102
|
from: AddressLike,
|
|
136
103
|
to: AddressLike,
|
|
@@ -6,11 +6,7 @@ export declare namespace ZebecCard {
|
|
|
6
6
|
maxAmount: BigNumberish;
|
|
7
7
|
fee: BigNumberish;
|
|
8
8
|
};
|
|
9
|
-
type FeeTierStructOutput = [
|
|
10
|
-
minAmount: bigint,
|
|
11
|
-
maxAmount: bigint,
|
|
12
|
-
fee: bigint
|
|
13
|
-
] & {
|
|
9
|
+
type FeeTierStructOutput = [minAmount: bigint, maxAmount: bigint, fee: bigint] & {
|
|
14
10
|
minAmount: bigint;
|
|
15
11
|
maxAmount: bigint;
|
|
16
12
|
fee: bigint;
|
|
@@ -347,19 +343,12 @@ export interface ZebecCard extends BaseContract {
|
|
|
347
343
|
cardPurchases: TypedContractMethod<[
|
|
348
344
|
arg0: AddressLike
|
|
349
345
|
], [
|
|
350
|
-
[
|
|
351
|
-
bigint,
|
|
352
|
-
bigint
|
|
353
|
-
] & {
|
|
346
|
+
[bigint, bigint] & {
|
|
354
347
|
unixInRecord: bigint;
|
|
355
348
|
totalCardBoughtPerDay: bigint;
|
|
356
349
|
}
|
|
357
350
|
], "view">;
|
|
358
|
-
depositUsdc: TypedContractMethod<[
|
|
359
|
-
amount: BigNumberish
|
|
360
|
-
], [
|
|
361
|
-
void
|
|
362
|
-
], "nonpayable">;
|
|
351
|
+
depositUsdc: TypedContractMethod<[amount: BigNumberish], [void], "nonpayable">;
|
|
363
352
|
feeTiers: TypedContractMethod<[
|
|
364
353
|
arg0: BigNumberish
|
|
365
354
|
], [
|
|
@@ -373,16 +362,9 @@ export interface ZebecCard extends BaseContract {
|
|
|
373
362
|
fee: bigint;
|
|
374
363
|
}
|
|
375
364
|
], "view">;
|
|
376
|
-
generateYield: TypedContractMethod<[
|
|
377
|
-
amount: BigNumberish
|
|
378
|
-
], [
|
|
379
|
-
void
|
|
380
|
-
], "nonpayable">;
|
|
365
|
+
generateYield: TypedContractMethod<[amount: BigNumberish], [void], "nonpayable">;
|
|
381
366
|
getFee: TypedContractMethod<[amount: BigNumberish], [bigint], "view">;
|
|
382
|
-
getFeeTiers: TypedContractMethod<[
|
|
383
|
-
], [
|
|
384
|
-
ZebecCard.FeeTierStructOutput[]
|
|
385
|
-
], "view">;
|
|
367
|
+
getFeeTiers: TypedContractMethod<[], [ZebecCard.FeeTierStructOutput[]], "view">;
|
|
386
368
|
initialize: TypedContractMethod<[
|
|
387
369
|
card_config: ZebecCard.CardConfigStruct,
|
|
388
370
|
fee_tiers: ZebecCard.FeeTierStruct[],
|
|
@@ -397,16 +379,8 @@ export interface ZebecCard extends BaseContract {
|
|
|
397
379
|
owner: TypedContractMethod<[], [string], "view">;
|
|
398
380
|
proxiableUUID: TypedContractMethod<[], [string], "view">;
|
|
399
381
|
renounceOwnership: TypedContractMethod<[], [void], "nonpayable">;
|
|
400
|
-
setCardVault: TypedContractMethod<[
|
|
401
|
-
|
|
402
|
-
], [
|
|
403
|
-
void
|
|
404
|
-
], "nonpayable">;
|
|
405
|
-
setComissionVault: TypedContractMethod<[
|
|
406
|
-
commissionVault: AddressLike
|
|
407
|
-
], [
|
|
408
|
-
void
|
|
409
|
-
], "nonpayable">;
|
|
382
|
+
setCardVault: TypedContractMethod<[cardVault: AddressLike], [void], "nonpayable">;
|
|
383
|
+
setComissionVault: TypedContractMethod<[commissionVault: AddressLike], [void], "nonpayable">;
|
|
410
384
|
setDailyCardBuyLimit: TypedContractMethod<[
|
|
411
385
|
dailyCardBuyLimit: BigNumberish
|
|
412
386
|
], [
|
|
@@ -419,46 +393,14 @@ export interface ZebecCard extends BaseContract {
|
|
|
419
393
|
], [
|
|
420
394
|
void
|
|
421
395
|
], "nonpayable">;
|
|
422
|
-
setFeeArray: TypedContractMethod<[
|
|
423
|
-
|
|
424
|
-
], [
|
|
425
|
-
|
|
426
|
-
], "nonpayable">;
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
], [
|
|
430
|
-
void
|
|
431
|
-
], "nonpayable">;
|
|
432
|
-
setMinCardAmount: TypedContractMethod<[
|
|
433
|
-
minAmount: BigNumberish
|
|
434
|
-
], [
|
|
435
|
-
void
|
|
436
|
-
], "nonpayable">;
|
|
437
|
-
setNativeFee: TypedContractMethod<[
|
|
438
|
-
nativeFee: BigNumberish
|
|
439
|
-
], [
|
|
440
|
-
void
|
|
441
|
-
], "nonpayable">;
|
|
442
|
-
setNonNativeFee: TypedContractMethod<[
|
|
443
|
-
nonNativeFee: BigNumberish
|
|
444
|
-
], [
|
|
445
|
-
void
|
|
446
|
-
], "nonpayable">;
|
|
447
|
-
setRevenueFee: TypedContractMethod<[
|
|
448
|
-
revenueFee: BigNumberish
|
|
449
|
-
], [
|
|
450
|
-
void
|
|
451
|
-
], "nonpayable">;
|
|
452
|
-
setRevenueVault: TypedContractMethod<[
|
|
453
|
-
revenueVault: AddressLike
|
|
454
|
-
], [
|
|
455
|
-
void
|
|
456
|
-
], "nonpayable">;
|
|
457
|
-
setUsdcAddress: TypedContractMethod<[
|
|
458
|
-
usdcAddress: AddressLike
|
|
459
|
-
], [
|
|
460
|
-
void
|
|
461
|
-
], "nonpayable">;
|
|
396
|
+
setFeeArray: TypedContractMethod<[newTiers: ZebecCard.FeeTierStruct[]], [void], "nonpayable">;
|
|
397
|
+
setMaxCardAmount: TypedContractMethod<[maxAmount: BigNumberish], [void], "nonpayable">;
|
|
398
|
+
setMinCardAmount: TypedContractMethod<[minAmount: BigNumberish], [void], "nonpayable">;
|
|
399
|
+
setNativeFee: TypedContractMethod<[nativeFee: BigNumberish], [void], "nonpayable">;
|
|
400
|
+
setNonNativeFee: TypedContractMethod<[nonNativeFee: BigNumberish], [void], "nonpayable">;
|
|
401
|
+
setRevenueFee: TypedContractMethod<[revenueFee: BigNumberish], [void], "nonpayable">;
|
|
402
|
+
setRevenueVault: TypedContractMethod<[revenueVault: AddressLike], [void], "nonpayable">;
|
|
403
|
+
setUsdcAddress: TypedContractMethod<[usdcAddress: AddressLike], [void], "nonpayable">;
|
|
462
404
|
swapAndDeposit: TypedContractMethod<[
|
|
463
405
|
executor: AddressLike,
|
|
464
406
|
desc: IAggregationRouterV6.SwapDescriptionStruct,
|
|
@@ -466,11 +408,7 @@ export interface ZebecCard extends BaseContract {
|
|
|
466
408
|
], [
|
|
467
409
|
void
|
|
468
410
|
], "payable">;
|
|
469
|
-
transferOwnership: TypedContractMethod<[
|
|
470
|
-
newOwner: AddressLike
|
|
471
|
-
], [
|
|
472
|
-
void
|
|
473
|
-
], "nonpayable">;
|
|
411
|
+
transferOwnership: TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">;
|
|
474
412
|
upgradeToAndCall: TypedContractMethod<[
|
|
475
413
|
newImplementation: AddressLike,
|
|
476
414
|
data: BytesLike
|
|
@@ -479,11 +417,7 @@ export interface ZebecCard extends BaseContract {
|
|
|
479
417
|
], "payable">;
|
|
480
418
|
wEth: TypedContractMethod<[], [string], "view">;
|
|
481
419
|
withdraw: TypedContractMethod<[amount: BigNumberish], [void], "nonpayable">;
|
|
482
|
-
withdrawYield: TypedContractMethod<[
|
|
483
|
-
amount: BigNumberish
|
|
484
|
-
], [
|
|
485
|
-
void
|
|
486
|
-
], "nonpayable">;
|
|
420
|
+
withdrawYield: TypedContractMethod<[amount: BigNumberish], [void], "nonpayable">;
|
|
487
421
|
zebecToken: TypedContractMethod<[], [string], "view">;
|
|
488
422
|
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
|
|
489
423
|
getFunction(nameOrSignature: "UPGRADE_INTERFACE_VERSION"): TypedContractMethod<[], [string], "view">;
|
|
@@ -527,10 +461,7 @@ export interface ZebecCard extends BaseContract {
|
|
|
527
461
|
getFunction(nameOrSignature: "cardPurchases"): TypedContractMethod<[
|
|
528
462
|
arg0: AddressLike
|
|
529
463
|
], [
|
|
530
|
-
[
|
|
531
|
-
bigint,
|
|
532
|
-
bigint
|
|
533
|
-
] & {
|
|
464
|
+
[bigint, bigint] & {
|
|
534
465
|
unixInRecord: bigint;
|
|
535
466
|
totalCardBoughtPerDay: bigint;
|
|
536
467
|
}
|
|
@@ -568,11 +499,7 @@ export interface ZebecCard extends BaseContract {
|
|
|
568
499
|
getFunction(nameOrSignature: "renounceOwnership"): TypedContractMethod<[], [void], "nonpayable">;
|
|
569
500
|
getFunction(nameOrSignature: "setCardVault"): TypedContractMethod<[cardVault: AddressLike], [void], "nonpayable">;
|
|
570
501
|
getFunction(nameOrSignature: "setComissionVault"): TypedContractMethod<[commissionVault: AddressLike], [void], "nonpayable">;
|
|
571
|
-
getFunction(nameOrSignature: "setDailyCardBuyLimit"): TypedContractMethod<[
|
|
572
|
-
dailyCardBuyLimit: BigNumberish
|
|
573
|
-
], [
|
|
574
|
-
void
|
|
575
|
-
], "nonpayable">;
|
|
502
|
+
getFunction(nameOrSignature: "setDailyCardBuyLimit"): TypedContractMethod<[dailyCardBuyLimit: BigNumberish], [void], "nonpayable">;
|
|
576
503
|
getFunction(nameOrSignature: "setFee"): TypedContractMethod<[
|
|
577
504
|
minAmount: BigNumberish,
|
|
578
505
|
maxAmount: BigNumberish,
|
|
@@ -580,11 +507,7 @@ export interface ZebecCard extends BaseContract {
|
|
|
580
507
|
], [
|
|
581
508
|
void
|
|
582
509
|
], "nonpayable">;
|
|
583
|
-
getFunction(nameOrSignature: "setFeeArray"): TypedContractMethod<[
|
|
584
|
-
newTiers: ZebecCard.FeeTierStruct[]
|
|
585
|
-
], [
|
|
586
|
-
void
|
|
587
|
-
], "nonpayable">;
|
|
510
|
+
getFunction(nameOrSignature: "setFeeArray"): TypedContractMethod<[newTiers: ZebecCard.FeeTierStruct[]], [void], "nonpayable">;
|
|
588
511
|
getFunction(nameOrSignature: "setMaxCardAmount"): TypedContractMethod<[maxAmount: BigNumberish], [void], "nonpayable">;
|
|
589
512
|
getFunction(nameOrSignature: "setMinCardAmount"): TypedContractMethod<[minAmount: BigNumberish], [void], "nonpayable">;
|
|
590
513
|
getFunction(nameOrSignature: "setNativeFee"): TypedContractMethod<[nativeFee: BigNumberish], [void], "nonpayable">;
|
|
@@ -600,12 +523,7 @@ export interface ZebecCard extends BaseContract {
|
|
|
600
523
|
void
|
|
601
524
|
], "payable">;
|
|
602
525
|
getFunction(nameOrSignature: "transferOwnership"): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">;
|
|
603
|
-
getFunction(nameOrSignature: "upgradeToAndCall"): TypedContractMethod<[
|
|
604
|
-
newImplementation: AddressLike,
|
|
605
|
-
data: BytesLike
|
|
606
|
-
], [
|
|
607
|
-
void
|
|
608
|
-
], "payable">;
|
|
526
|
+
getFunction(nameOrSignature: "upgradeToAndCall"): TypedContractMethod<[newImplementation: AddressLike, data: BytesLike], [void], "payable">;
|
|
609
527
|
getFunction(nameOrSignature: "wEth"): TypedContractMethod<[], [string], "view">;
|
|
610
528
|
getFunction(nameOrSignature: "withdraw"): TypedContractMethod<[amount: BigNumberish], [void], "nonpayable">;
|
|
611
529
|
getFunction(nameOrSignature: "withdrawYield"): TypedContractMethod<[amount: BigNumberish], [void], "nonpayable">;
|
|
@@ -15,11 +15,7 @@ export interface TypedEventLog<TCEvent extends TypedContractEvent> extends Omit<
|
|
|
15
15
|
export interface TypedLogDescription<TCEvent extends TypedContractEvent> extends Omit<LogDescription, "args"> {
|
|
16
16
|
args: __TypechainAOutputTuple<TCEvent> & __TypechainOutputObject<TCEvent>;
|
|
17
17
|
}
|
|
18
|
-
export type TypedListener<TCEvent extends TypedContractEvent> = (...listenerArg: [
|
|
19
|
-
...__TypechainAOutputTuple<TCEvent>,
|
|
20
|
-
TypedEventLog<TCEvent>,
|
|
21
|
-
...undefined[]
|
|
22
|
-
]) => void;
|
|
18
|
+
export type TypedListener<TCEvent extends TypedContractEvent> = (...listenerArg: [...__TypechainAOutputTuple<TCEvent>, TypedEventLog<TCEvent>, ...undefined[]]) => void;
|
|
23
19
|
export type MinEthersFactory<C, ARGS> = {
|
|
24
20
|
deploy(...a: ARGS[]): Promise<C>;
|
|
25
21
|
};
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.ZebecCard__factory = exports.ERC20__factory = exports.factories = void 0;
|
|
27
37
|
exports.factories = __importStar(require("./factories"));
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { SupportedChain } from
|
|
1
|
+
import { SupportedChain } from "./chains";
|
|
2
2
|
export declare const ZEBEC_CARD_ADDRESS: Record<SupportedChain, string>;
|
|
3
3
|
export declare const USDC_ADDRESS: Record<SupportedChain, string>;
|
|
4
4
|
export declare const CARD_API_URL: Record<"Production" | "Sandbox", string>;
|
|
5
5
|
export declare const TAO_RPC_URL: Record<"Production" | "Sandbox", string>;
|
|
6
6
|
export declare const TON_RPC_URL: Record<"Production" | "Sandbox", string>;
|
|
7
7
|
export declare const DIGITALBITS_RPC_URL: Record<"Production" | "Sandbox", string>;
|
|
8
|
+
export declare const XDB_PASSPHRASE: Record<"Production" | "Sandbox", string>;
|
|
8
9
|
export declare const STELLAR_RPC_URL: Record<"Production" | "Sandbox", string>;
|
|
9
10
|
export declare const COUNTRIES_WITH_CCA3: readonly [{
|
|
10
11
|
readonly name: {
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PLATFORM_FEE = exports.COUNTRIES_WITH_CCA3 = exports.STELLAR_RPC_URL = exports.DIGITALBITS_RPC_URL = exports.TON_RPC_URL = exports.TAO_RPC_URL = exports.CARD_API_URL = exports.USDC_ADDRESS = exports.ZEBEC_CARD_ADDRESS = void 0;
|
|
3
|
+
exports.PLATFORM_FEE = exports.COUNTRIES_WITH_CCA3 = exports.STELLAR_RPC_URL = exports.XDB_PASSPHRASE = exports.DIGITALBITS_RPC_URL = exports.TON_RPC_URL = exports.TAO_RPC_URL = exports.CARD_API_URL = exports.USDC_ADDRESS = exports.ZEBEC_CARD_ADDRESS = void 0;
|
|
4
4
|
const chains_1 = require("./chains");
|
|
5
5
|
exports.ZEBEC_CARD_ADDRESS = {
|
|
6
6
|
[chains_1.SupportedChain.Sepolia]: "0x00d90625CcaB01eA0e589DFd3C99972180CE609A",
|
|
@@ -44,6 +44,10 @@ exports.DIGITALBITS_RPC_URL = {
|
|
|
44
44
|
Production: "https://horizon.livenet.xdbchain.com",
|
|
45
45
|
Sandbox: "https://horizon.futurenet.xdbchain.com",
|
|
46
46
|
};
|
|
47
|
+
exports.XDB_PASSPHRASE = {
|
|
48
|
+
Production: "LiveNet Global XDBChain Network ; November 2023",
|
|
49
|
+
Sandbox: "Futurenet XDBChain Network ; October 2023",
|
|
50
|
+
};
|
|
47
51
|
exports.STELLAR_RPC_URL = {
|
|
48
52
|
Production: "https://stellar-mainnet.liquify.com/api=41EEWAH79Y5OCGI7/mainnet",
|
|
49
53
|
Sandbox: "https://horizon-testnet.stellar.org",
|
|
@@ -24,7 +24,7 @@ export declare class ZebecCardAPIService {
|
|
|
24
24
|
purchaseCard(data: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
25
25
|
fetchQuote(symbol: string): Promise<Quote>;
|
|
26
26
|
fetchVault(symbol: string): Promise<{
|
|
27
|
-
|
|
27
|
+
address: string;
|
|
28
28
|
tag?: string;
|
|
29
29
|
}>;
|
|
30
30
|
}
|
|
@@ -82,11 +82,11 @@ class ZebecCardAPIService {
|
|
|
82
82
|
async fetchQuote(symbol) {
|
|
83
83
|
const response = await this.api.get("/exchange/price", { params: { symbol } });
|
|
84
84
|
const data = response.data;
|
|
85
|
-
return data;
|
|
85
|
+
return data.data;
|
|
86
86
|
}
|
|
87
87
|
async fetchVault(symbol) {
|
|
88
88
|
const { data } = await this.api.get(`/exchange/deposit-address`, { params: { symbol } });
|
|
89
|
-
return data;
|
|
89
|
+
return data.data;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
exports.ZebecCardAPIService = ZebecCardAPIService;
|
|
@@ -76,7 +76,7 @@ class ZebecCardTONService {
|
|
|
76
76
|
throw new Error("Invalid wallet account");
|
|
77
77
|
}
|
|
78
78
|
// Fetch deposit address
|
|
79
|
-
const {
|
|
79
|
+
const { address: depositAddress, tag } = await this.fetchVault();
|
|
80
80
|
const walletAddress = new tonweb_1.default.utils.Address(this.signer.account.address).toString(true, true, false, this.sandbox);
|
|
81
81
|
// Calculate fees and total amount
|
|
82
82
|
const platform_fee = (params.amount * constants_1.PLATFORM_FEE) / 10000;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { StellarWalletsKit } from "@creit.tech/stellar-wallets-kit";
|
|
1
2
|
import { APIConfig } from "../helpers/apiHelpers";
|
|
2
|
-
import { Keypair } from "xdb-digitalbits-sdk";
|
|
3
3
|
import { Quote } from "../types";
|
|
4
|
-
export declare class
|
|
5
|
-
readonly
|
|
4
|
+
export declare class StellarService {
|
|
5
|
+
readonly kit: StellarWalletsKit;
|
|
6
6
|
private apiService;
|
|
7
7
|
private server;
|
|
8
8
|
private sandbox;
|
|
@@ -13,7 +13,7 @@ export declare class ZebecXdbService {
|
|
|
13
13
|
* @param {APIConfig} apiConfig - The configuration object for the API.
|
|
14
14
|
* @param sdkOptions - Optional configuration for the SDK.
|
|
15
15
|
*/
|
|
16
|
-
constructor(
|
|
16
|
+
constructor(kit: StellarWalletsKit, apiConfig: APIConfig, sdkOptions?: {
|
|
17
17
|
sandbox?: boolean;
|
|
18
18
|
apiKey?: string;
|
|
19
19
|
});
|
|
@@ -30,24 +30,18 @@ export declare class ZebecXdbService {
|
|
|
30
30
|
* @returns {Promise<string>} A promise that resolves to the Vault address.
|
|
31
31
|
*/
|
|
32
32
|
fetchVault(): Promise<{
|
|
33
|
-
|
|
33
|
+
address: string;
|
|
34
34
|
tag?: string;
|
|
35
35
|
}>;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Purchases a card by transferring XDB tokens.
|
|
38
38
|
*
|
|
39
|
-
* @param params - The parameters required
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
43
|
-
* @returns A promise that resolves to the transaction hash.
|
|
44
|
-
* @throws {Error} If there is not enough balance or if the transaction fails.
|
|
39
|
+
* @param params - The parameters required to purchase a card.
|
|
40
|
+
* @returns A promise that resolves to an array containing the transaction details and the API response.
|
|
41
|
+
* @throws {InvalidEmailError} If the recipient's email address is invalid.
|
|
42
|
+
* @throws {Error} If the quote is invalid or expired, if there is not enough balance, or if the transaction fails.
|
|
45
43
|
*/
|
|
46
|
-
transferXDB(
|
|
47
|
-
amount: string;
|
|
48
|
-
depositAddress: string;
|
|
49
|
-
tag?: string;
|
|
50
|
-
}): Promise<string>;
|
|
44
|
+
transferXDB(amount: number): Promise<string>;
|
|
51
45
|
/**
|
|
52
46
|
* Retrieves the balance of the specified wallet.
|
|
53
47
|
*
|
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
3
|
+
exports.StellarService = void 0;
|
|
4
|
+
const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
27
5
|
const constants_1 = require("../constants");
|
|
28
6
|
const apiHelpers_1 = require("../helpers/apiHelpers");
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
signer;
|
|
7
|
+
class StellarService {
|
|
8
|
+
kit;
|
|
32
9
|
apiService;
|
|
33
10
|
server;
|
|
34
11
|
sandbox;
|
|
@@ -39,11 +16,11 @@ class ZebecXdbService {
|
|
|
39
16
|
* @param {APIConfig} apiConfig - The configuration object for the API.
|
|
40
17
|
* @param sdkOptions - Optional configuration for the SDK.
|
|
41
18
|
*/
|
|
42
|
-
constructor(
|
|
43
|
-
this.
|
|
19
|
+
constructor(kit, apiConfig, sdkOptions) {
|
|
20
|
+
this.kit = kit;
|
|
44
21
|
const sandbox = sdkOptions?.sandbox ? sdkOptions.sandbox : false;
|
|
45
22
|
this.apiService = new apiHelpers_1.ZebecCardAPIService(apiConfig, sandbox);
|
|
46
|
-
this.server = new
|
|
23
|
+
this.server = new stellar_sdk_1.Horizon.Server(sandbox ? constants_1.DIGITALBITS_RPC_URL.Sandbox : constants_1.DIGITALBITS_RPC_URL.Production);
|
|
47
24
|
this.sandbox = sandbox;
|
|
48
25
|
}
|
|
49
26
|
/**
|
|
@@ -66,51 +43,56 @@ class ZebecXdbService {
|
|
|
66
43
|
return data;
|
|
67
44
|
}
|
|
68
45
|
/**
|
|
69
|
-
*
|
|
46
|
+
* Purchases a card by transferring XDB tokens.
|
|
70
47
|
*
|
|
71
|
-
* @param params - The parameters required
|
|
72
|
-
* @
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
75
|
-
* @returns A promise that resolves to the transaction hash.
|
|
76
|
-
* @throws {Error} If there is not enough balance or if the transaction fails.
|
|
48
|
+
* @param params - The parameters required to purchase a card.
|
|
49
|
+
* @returns A promise that resolves to an array containing the transaction details and the API response.
|
|
50
|
+
* @throws {InvalidEmailError} If the recipient's email address is invalid.
|
|
51
|
+
* @throws {Error} If the quote is invalid or expired, if there is not enough balance, or if the transaction fails.
|
|
77
52
|
*/
|
|
78
|
-
async transferXDB(
|
|
53
|
+
async transferXDB(amount) {
|
|
54
|
+
// Fetch deposit address
|
|
55
|
+
const vault = await this.fetchVault();
|
|
56
|
+
console.log("depositAddress", vault.address);
|
|
57
|
+
console.log("tag", vault.tag);
|
|
58
|
+
const accountAddress = await this.kit.getAddress();
|
|
79
59
|
// Prepare transaction
|
|
80
|
-
const account = await this.server.loadAccount(
|
|
60
|
+
const account = await this.server.loadAccount(accountAddress.address);
|
|
81
61
|
const fee = await this.server.fetchBaseFee();
|
|
82
|
-
const
|
|
62
|
+
const platform_fee = (amount * constants_1.PLATFORM_FEE) / 10000;
|
|
63
|
+
const totalAmount = (amount + platform_fee).toString();
|
|
64
|
+
const memo = stellar_sdk_1.Memo.id(vault.tag?.toString() || "");
|
|
83
65
|
// Check Wallet balance
|
|
84
|
-
const balance = await this.getWalletBalance(
|
|
85
|
-
if (Number(balance) < Number(
|
|
66
|
+
const balance = await this.getWalletBalance(accountAddress.address);
|
|
67
|
+
if (Number(balance) < Number(totalAmount)) {
|
|
86
68
|
throw new Error("Insufficient balance");
|
|
87
69
|
}
|
|
88
70
|
// Build and submit transaction
|
|
89
|
-
const transaction = new
|
|
90
|
-
fee,
|
|
91
|
-
networkPassphrase: this.sandbox
|
|
92
|
-
? xdb_digitalbits_sdk_1.default.Networks.TESTNET
|
|
93
|
-
: xdb_digitalbits_sdk_1.default.Networks.MAINNET,
|
|
71
|
+
const transaction = new stellar_sdk_1.TransactionBuilder(account, {
|
|
72
|
+
fee: fee.toString(),
|
|
73
|
+
networkPassphrase: this.sandbox ? constants_1.XDB_PASSPHRASE.Sandbox : constants_1.XDB_PASSPHRASE.Production,
|
|
94
74
|
})
|
|
95
|
-
.addOperation(
|
|
96
|
-
destination:
|
|
97
|
-
asset:
|
|
98
|
-
amount:
|
|
75
|
+
.addOperation(stellar_sdk_1.Operation.payment({
|
|
76
|
+
destination: vault.address,
|
|
77
|
+
asset: stellar_sdk_1.Asset.native(),
|
|
78
|
+
amount: totalAmount,
|
|
99
79
|
}))
|
|
100
80
|
.addMemo(memo)
|
|
101
|
-
.setTimeout(
|
|
81
|
+
.setTimeout(stellar_sdk_1.TimeoutInfinite)
|
|
102
82
|
.build();
|
|
103
83
|
// Sign the transaction
|
|
104
|
-
transaction.
|
|
84
|
+
const { signedTxXdr } = await this.kit.signTransaction(transaction.toXDR());
|
|
85
|
+
const tx = stellar_sdk_1.TransactionBuilder.fromXDR(signedTxXdr, this.sandbox ? stellar_sdk_1.Networks.TESTNET : stellar_sdk_1.Networks.PUBLIC);
|
|
105
86
|
let retries = 0;
|
|
106
87
|
const maxRetries = 5;
|
|
107
88
|
let delay = 1000;
|
|
108
89
|
while (retries < maxRetries) {
|
|
109
90
|
try {
|
|
110
|
-
const transactionResult = await this.server.submitTransaction(
|
|
91
|
+
const transactionResult = await this.server.submitTransaction(tx, {
|
|
111
92
|
skipMemoRequiredCheck: false,
|
|
112
93
|
});
|
|
113
|
-
|
|
94
|
+
const txHash = transactionResult.hash;
|
|
95
|
+
return txHash;
|
|
114
96
|
}
|
|
115
97
|
catch (error) {
|
|
116
98
|
console.debug("error: ", error);
|
|
@@ -137,4 +119,4 @@ class ZebecXdbService {
|
|
|
137
119
|
return nativeBalance ? nativeBalance.balance : "0";
|
|
138
120
|
}
|
|
139
121
|
}
|
|
140
|
-
exports.
|
|
122
|
+
exports.StellarService = StellarService;
|