@loyal-labs/private-transactions 0.2.2 → 0.2.4
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 +98 -80
- package/dist/index.d.ts +22 -185
- package/dist/index.js +76 -477
- package/dist/src/LoyalPrivateTransactionsClient.d.ts +14 -21
- package/dist/src/constants.d.ts +13 -6
- package/dist/src/idl/telegram_private_transfer.d.ts +38 -408
- package/dist/src/idl.d.ts +8 -8
- package/dist/src/types.d.ts +0 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18133,7 +18133,7 @@ https://github.com/browserify/crypto-browserify`);
|
|
|
18133
18133
|
crypto_default = crypto;
|
|
18134
18134
|
});
|
|
18135
18135
|
|
|
18136
|
-
// node_modules/tweetnacl/nacl-fast.js
|
|
18136
|
+
// ../../node_modules/tweetnacl/nacl-fast.js
|
|
18137
18137
|
var require_nacl_fast = __commonJS((exports, module) => {
|
|
18138
18138
|
(function(nacl) {
|
|
18139
18139
|
var gf = function(init) {
|
|
@@ -20459,199 +20459,10 @@ var telegram_private_transfer_default = {
|
|
|
20459
20459
|
},
|
|
20460
20460
|
instructions: [
|
|
20461
20461
|
{
|
|
20462
|
-
name: "
|
|
20462
|
+
name: "claim_username_deposit_to_deposit",
|
|
20463
20463
|
docs: [
|
|
20464
|
-
"
|
|
20464
|
+
"Claim tokens and transfer from username deposit to deposit"
|
|
20465
20465
|
],
|
|
20466
|
-
discriminator: [
|
|
20467
|
-
73,
|
|
20468
|
-
62,
|
|
20469
|
-
148,
|
|
20470
|
-
70,
|
|
20471
|
-
186,
|
|
20472
|
-
247,
|
|
20473
|
-
37,
|
|
20474
|
-
80
|
|
20475
|
-
],
|
|
20476
|
-
accounts: [
|
|
20477
|
-
{
|
|
20478
|
-
name: "recipient_token_account",
|
|
20479
|
-
writable: true
|
|
20480
|
-
},
|
|
20481
|
-
{
|
|
20482
|
-
name: "vault",
|
|
20483
|
-
writable: true,
|
|
20484
|
-
pda: {
|
|
20485
|
-
seeds: [
|
|
20486
|
-
{
|
|
20487
|
-
kind: "const",
|
|
20488
|
-
value: [
|
|
20489
|
-
118,
|
|
20490
|
-
97,
|
|
20491
|
-
117,
|
|
20492
|
-
108,
|
|
20493
|
-
116
|
|
20494
|
-
]
|
|
20495
|
-
},
|
|
20496
|
-
{
|
|
20497
|
-
kind: "account",
|
|
20498
|
-
path: "token_mint"
|
|
20499
|
-
}
|
|
20500
|
-
]
|
|
20501
|
-
}
|
|
20502
|
-
},
|
|
20503
|
-
{
|
|
20504
|
-
name: "vault_token_account",
|
|
20505
|
-
writable: true,
|
|
20506
|
-
pda: {
|
|
20507
|
-
seeds: [
|
|
20508
|
-
{
|
|
20509
|
-
kind: "account",
|
|
20510
|
-
path: "vault"
|
|
20511
|
-
},
|
|
20512
|
-
{
|
|
20513
|
-
kind: "const",
|
|
20514
|
-
value: [
|
|
20515
|
-
6,
|
|
20516
|
-
221,
|
|
20517
|
-
246,
|
|
20518
|
-
225,
|
|
20519
|
-
215,
|
|
20520
|
-
101,
|
|
20521
|
-
161,
|
|
20522
|
-
147,
|
|
20523
|
-
217,
|
|
20524
|
-
203,
|
|
20525
|
-
225,
|
|
20526
|
-
70,
|
|
20527
|
-
206,
|
|
20528
|
-
235,
|
|
20529
|
-
121,
|
|
20530
|
-
172,
|
|
20531
|
-
28,
|
|
20532
|
-
180,
|
|
20533
|
-
133,
|
|
20534
|
-
237,
|
|
20535
|
-
95,
|
|
20536
|
-
91,
|
|
20537
|
-
55,
|
|
20538
|
-
145,
|
|
20539
|
-
58,
|
|
20540
|
-
140,
|
|
20541
|
-
245,
|
|
20542
|
-
133,
|
|
20543
|
-
126,
|
|
20544
|
-
255,
|
|
20545
|
-
0,
|
|
20546
|
-
169
|
|
20547
|
-
]
|
|
20548
|
-
},
|
|
20549
|
-
{
|
|
20550
|
-
kind: "account",
|
|
20551
|
-
path: "token_mint"
|
|
20552
|
-
}
|
|
20553
|
-
],
|
|
20554
|
-
program: {
|
|
20555
|
-
kind: "const",
|
|
20556
|
-
value: [
|
|
20557
|
-
140,
|
|
20558
|
-
151,
|
|
20559
|
-
37,
|
|
20560
|
-
143,
|
|
20561
|
-
78,
|
|
20562
|
-
36,
|
|
20563
|
-
137,
|
|
20564
|
-
241,
|
|
20565
|
-
187,
|
|
20566
|
-
61,
|
|
20567
|
-
16,
|
|
20568
|
-
41,
|
|
20569
|
-
20,
|
|
20570
|
-
142,
|
|
20571
|
-
13,
|
|
20572
|
-
131,
|
|
20573
|
-
11,
|
|
20574
|
-
90,
|
|
20575
|
-
19,
|
|
20576
|
-
153,
|
|
20577
|
-
218,
|
|
20578
|
-
255,
|
|
20579
|
-
16,
|
|
20580
|
-
132,
|
|
20581
|
-
4,
|
|
20582
|
-
142,
|
|
20583
|
-
123,
|
|
20584
|
-
216,
|
|
20585
|
-
219,
|
|
20586
|
-
233,
|
|
20587
|
-
248,
|
|
20588
|
-
89
|
|
20589
|
-
]
|
|
20590
|
-
}
|
|
20591
|
-
}
|
|
20592
|
-
},
|
|
20593
|
-
{
|
|
20594
|
-
name: "deposit",
|
|
20595
|
-
writable: true,
|
|
20596
|
-
pda: {
|
|
20597
|
-
seeds: [
|
|
20598
|
-
{
|
|
20599
|
-
kind: "const",
|
|
20600
|
-
value: [
|
|
20601
|
-
117,
|
|
20602
|
-
115,
|
|
20603
|
-
101,
|
|
20604
|
-
114,
|
|
20605
|
-
110,
|
|
20606
|
-
97,
|
|
20607
|
-
109,
|
|
20608
|
-
101,
|
|
20609
|
-
95,
|
|
20610
|
-
100,
|
|
20611
|
-
101,
|
|
20612
|
-
112,
|
|
20613
|
-
111,
|
|
20614
|
-
115,
|
|
20615
|
-
105,
|
|
20616
|
-
116
|
|
20617
|
-
]
|
|
20618
|
-
},
|
|
20619
|
-
{
|
|
20620
|
-
kind: "account",
|
|
20621
|
-
path: "deposit.username",
|
|
20622
|
-
account: "UsernameDeposit"
|
|
20623
|
-
},
|
|
20624
|
-
{
|
|
20625
|
-
kind: "account",
|
|
20626
|
-
path: "deposit.token_mint",
|
|
20627
|
-
account: "UsernameDeposit"
|
|
20628
|
-
}
|
|
20629
|
-
]
|
|
20630
|
-
}
|
|
20631
|
-
},
|
|
20632
|
-
{
|
|
20633
|
-
name: "token_mint",
|
|
20634
|
-
relations: [
|
|
20635
|
-
"deposit"
|
|
20636
|
-
]
|
|
20637
|
-
},
|
|
20638
|
-
{
|
|
20639
|
-
name: "session"
|
|
20640
|
-
},
|
|
20641
|
-
{
|
|
20642
|
-
name: "token_program",
|
|
20643
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
20644
|
-
}
|
|
20645
|
-
],
|
|
20646
|
-
args: [
|
|
20647
|
-
{
|
|
20648
|
-
name: "amount",
|
|
20649
|
-
type: "u64"
|
|
20650
|
-
}
|
|
20651
|
-
]
|
|
20652
|
-
},
|
|
20653
|
-
{
|
|
20654
|
-
name: "claim_username_deposit_to_deposit",
|
|
20655
20466
|
discriminator: [
|
|
20656
20467
|
147,
|
|
20657
20468
|
77,
|
|
@@ -20722,7 +20533,10 @@ var telegram_private_transfer_default = {
|
|
|
20722
20533
|
111,
|
|
20723
20534
|
115,
|
|
20724
20535
|
105,
|
|
20725
|
-
116
|
|
20536
|
+
116,
|
|
20537
|
+
95,
|
|
20538
|
+
118,
|
|
20539
|
+
50
|
|
20726
20540
|
]
|
|
20727
20541
|
},
|
|
20728
20542
|
{
|
|
@@ -20800,7 +20614,10 @@ var telegram_private_transfer_default = {
|
|
|
20800
20614
|
111,
|
|
20801
20615
|
115,
|
|
20802
20616
|
105,
|
|
20803
|
-
116
|
|
20617
|
+
116,
|
|
20618
|
+
95,
|
|
20619
|
+
118,
|
|
20620
|
+
50
|
|
20804
20621
|
]
|
|
20805
20622
|
},
|
|
20806
20623
|
{
|
|
@@ -21081,7 +20898,10 @@ var telegram_private_transfer_default = {
|
|
|
21081
20898
|
111,
|
|
21082
20899
|
115,
|
|
21083
20900
|
105,
|
|
21084
|
-
116
|
|
20901
|
+
116,
|
|
20902
|
+
95,
|
|
20903
|
+
118,
|
|
20904
|
+
50
|
|
21085
20905
|
]
|
|
21086
20906
|
},
|
|
21087
20907
|
{
|
|
@@ -21336,214 +21156,6 @@ var telegram_private_transfer_default = {
|
|
|
21336
21156
|
}
|
|
21337
21157
|
]
|
|
21338
21158
|
},
|
|
21339
|
-
{
|
|
21340
|
-
name: "deposit_for_username",
|
|
21341
|
-
docs: [
|
|
21342
|
-
"Deposits tokens into a username-based deposit.",
|
|
21343
|
-
"",
|
|
21344
|
-
"Anyone can deposit tokens for a Telegram username."
|
|
21345
|
-
],
|
|
21346
|
-
discriminator: [
|
|
21347
|
-
85,
|
|
21348
|
-
11,
|
|
21349
|
-
120,
|
|
21350
|
-
21,
|
|
21351
|
-
51,
|
|
21352
|
-
229,
|
|
21353
|
-
125,
|
|
21354
|
-
220
|
|
21355
|
-
],
|
|
21356
|
-
accounts: [
|
|
21357
|
-
{
|
|
21358
|
-
name: "payer",
|
|
21359
|
-
writable: true,
|
|
21360
|
-
signer: true
|
|
21361
|
-
},
|
|
21362
|
-
{
|
|
21363
|
-
name: "depositor",
|
|
21364
|
-
writable: true,
|
|
21365
|
-
signer: true
|
|
21366
|
-
},
|
|
21367
|
-
{
|
|
21368
|
-
name: "deposit",
|
|
21369
|
-
writable: true,
|
|
21370
|
-
pda: {
|
|
21371
|
-
seeds: [
|
|
21372
|
-
{
|
|
21373
|
-
kind: "const",
|
|
21374
|
-
value: [
|
|
21375
|
-
117,
|
|
21376
|
-
115,
|
|
21377
|
-
101,
|
|
21378
|
-
114,
|
|
21379
|
-
110,
|
|
21380
|
-
97,
|
|
21381
|
-
109,
|
|
21382
|
-
101,
|
|
21383
|
-
95,
|
|
21384
|
-
100,
|
|
21385
|
-
101,
|
|
21386
|
-
112,
|
|
21387
|
-
111,
|
|
21388
|
-
115,
|
|
21389
|
-
105,
|
|
21390
|
-
116
|
|
21391
|
-
]
|
|
21392
|
-
},
|
|
21393
|
-
{
|
|
21394
|
-
kind: "arg",
|
|
21395
|
-
path: "username"
|
|
21396
|
-
},
|
|
21397
|
-
{
|
|
21398
|
-
kind: "account",
|
|
21399
|
-
path: "token_mint"
|
|
21400
|
-
}
|
|
21401
|
-
]
|
|
21402
|
-
}
|
|
21403
|
-
},
|
|
21404
|
-
{
|
|
21405
|
-
name: "vault",
|
|
21406
|
-
writable: true,
|
|
21407
|
-
pda: {
|
|
21408
|
-
seeds: [
|
|
21409
|
-
{
|
|
21410
|
-
kind: "const",
|
|
21411
|
-
value: [
|
|
21412
|
-
118,
|
|
21413
|
-
97,
|
|
21414
|
-
117,
|
|
21415
|
-
108,
|
|
21416
|
-
116
|
|
21417
|
-
]
|
|
21418
|
-
},
|
|
21419
|
-
{
|
|
21420
|
-
kind: "account",
|
|
21421
|
-
path: "token_mint"
|
|
21422
|
-
}
|
|
21423
|
-
]
|
|
21424
|
-
}
|
|
21425
|
-
},
|
|
21426
|
-
{
|
|
21427
|
-
name: "vault_token_account",
|
|
21428
|
-
writable: true,
|
|
21429
|
-
pda: {
|
|
21430
|
-
seeds: [
|
|
21431
|
-
{
|
|
21432
|
-
kind: "account",
|
|
21433
|
-
path: "vault"
|
|
21434
|
-
},
|
|
21435
|
-
{
|
|
21436
|
-
kind: "const",
|
|
21437
|
-
value: [
|
|
21438
|
-
6,
|
|
21439
|
-
221,
|
|
21440
|
-
246,
|
|
21441
|
-
225,
|
|
21442
|
-
215,
|
|
21443
|
-
101,
|
|
21444
|
-
161,
|
|
21445
|
-
147,
|
|
21446
|
-
217,
|
|
21447
|
-
203,
|
|
21448
|
-
225,
|
|
21449
|
-
70,
|
|
21450
|
-
206,
|
|
21451
|
-
235,
|
|
21452
|
-
121,
|
|
21453
|
-
172,
|
|
21454
|
-
28,
|
|
21455
|
-
180,
|
|
21456
|
-
133,
|
|
21457
|
-
237,
|
|
21458
|
-
95,
|
|
21459
|
-
91,
|
|
21460
|
-
55,
|
|
21461
|
-
145,
|
|
21462
|
-
58,
|
|
21463
|
-
140,
|
|
21464
|
-
245,
|
|
21465
|
-
133,
|
|
21466
|
-
126,
|
|
21467
|
-
255,
|
|
21468
|
-
0,
|
|
21469
|
-
169
|
|
21470
|
-
]
|
|
21471
|
-
},
|
|
21472
|
-
{
|
|
21473
|
-
kind: "account",
|
|
21474
|
-
path: "token_mint"
|
|
21475
|
-
}
|
|
21476
|
-
],
|
|
21477
|
-
program: {
|
|
21478
|
-
kind: "const",
|
|
21479
|
-
value: [
|
|
21480
|
-
140,
|
|
21481
|
-
151,
|
|
21482
|
-
37,
|
|
21483
|
-
143,
|
|
21484
|
-
78,
|
|
21485
|
-
36,
|
|
21486
|
-
137,
|
|
21487
|
-
241,
|
|
21488
|
-
187,
|
|
21489
|
-
61,
|
|
21490
|
-
16,
|
|
21491
|
-
41,
|
|
21492
|
-
20,
|
|
21493
|
-
142,
|
|
21494
|
-
13,
|
|
21495
|
-
131,
|
|
21496
|
-
11,
|
|
21497
|
-
90,
|
|
21498
|
-
19,
|
|
21499
|
-
153,
|
|
21500
|
-
218,
|
|
21501
|
-
255,
|
|
21502
|
-
16,
|
|
21503
|
-
132,
|
|
21504
|
-
4,
|
|
21505
|
-
142,
|
|
21506
|
-
123,
|
|
21507
|
-
216,
|
|
21508
|
-
219,
|
|
21509
|
-
233,
|
|
21510
|
-
248,
|
|
21511
|
-
89
|
|
21512
|
-
]
|
|
21513
|
-
}
|
|
21514
|
-
}
|
|
21515
|
-
},
|
|
21516
|
-
{
|
|
21517
|
-
name: "depositor_token_account",
|
|
21518
|
-
writable: true
|
|
21519
|
-
},
|
|
21520
|
-
{
|
|
21521
|
-
name: "token_mint"
|
|
21522
|
-
},
|
|
21523
|
-
{
|
|
21524
|
-
name: "token_program",
|
|
21525
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
21526
|
-
},
|
|
21527
|
-
{
|
|
21528
|
-
name: "associated_token_program",
|
|
21529
|
-
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
21530
|
-
},
|
|
21531
|
-
{
|
|
21532
|
-
name: "system_program",
|
|
21533
|
-
address: "11111111111111111111111111111111"
|
|
21534
|
-
}
|
|
21535
|
-
],
|
|
21536
|
-
args: [
|
|
21537
|
-
{
|
|
21538
|
-
name: "username",
|
|
21539
|
-
type: "string"
|
|
21540
|
-
},
|
|
21541
|
-
{
|
|
21542
|
-
name: "amount",
|
|
21543
|
-
type: "u64"
|
|
21544
|
-
}
|
|
21545
|
-
]
|
|
21546
|
-
},
|
|
21547
21159
|
{
|
|
21548
21160
|
name: "initialize_deposit",
|
|
21549
21161
|
docs: [
|
|
@@ -21585,7 +21197,10 @@ var telegram_private_transfer_default = {
|
|
|
21585
21197
|
111,
|
|
21586
21198
|
115,
|
|
21587
21199
|
105,
|
|
21588
|
-
116
|
|
21200
|
+
116,
|
|
21201
|
+
95,
|
|
21202
|
+
118,
|
|
21203
|
+
50
|
|
21589
21204
|
]
|
|
21590
21205
|
},
|
|
21591
21206
|
{
|
|
@@ -21755,7 +21370,10 @@ var telegram_private_transfer_default = {
|
|
|
21755
21370
|
111,
|
|
21756
21371
|
115,
|
|
21757
21372
|
105,
|
|
21758
|
-
116
|
|
21373
|
+
116,
|
|
21374
|
+
95,
|
|
21375
|
+
118,
|
|
21376
|
+
50
|
|
21759
21377
|
]
|
|
21760
21378
|
},
|
|
21761
21379
|
{
|
|
@@ -22065,7 +21683,10 @@ var telegram_private_transfer_default = {
|
|
|
22065
21683
|
111,
|
|
22066
21684
|
115,
|
|
22067
21685
|
105,
|
|
22068
|
-
116
|
|
21686
|
+
116,
|
|
21687
|
+
95,
|
|
21688
|
+
118,
|
|
21689
|
+
50
|
|
22069
21690
|
]
|
|
22070
21691
|
},
|
|
22071
21692
|
{
|
|
@@ -22095,7 +21716,10 @@ var telegram_private_transfer_default = {
|
|
|
22095
21716
|
111,
|
|
22096
21717
|
115,
|
|
22097
21718
|
105,
|
|
22098
|
-
116
|
|
21719
|
+
116,
|
|
21720
|
+
95,
|
|
21721
|
+
118,
|
|
21722
|
+
50
|
|
22099
21723
|
]
|
|
22100
21724
|
},
|
|
22101
21725
|
{
|
|
@@ -22177,7 +21801,10 @@ var telegram_private_transfer_default = {
|
|
|
22177
21801
|
111,
|
|
22178
21802
|
115,
|
|
22179
21803
|
105,
|
|
22180
|
-
116
|
|
21804
|
+
116,
|
|
21805
|
+
95,
|
|
21806
|
+
118,
|
|
21807
|
+
50
|
|
22181
21808
|
]
|
|
22182
21809
|
},
|
|
22183
21810
|
{
|
|
@@ -22295,7 +21922,10 @@ var telegram_private_transfer_default = {
|
|
|
22295
21922
|
111,
|
|
22296
21923
|
115,
|
|
22297
21924
|
105,
|
|
22298
|
-
116
|
|
21925
|
+
116,
|
|
21926
|
+
95,
|
|
21927
|
+
118,
|
|
21928
|
+
50
|
|
22299
21929
|
]
|
|
22300
21930
|
},
|
|
22301
21931
|
{
|
|
@@ -22676,13 +22306,21 @@ var telegram_private_transfer_default = {
|
|
|
22676
22306
|
|
|
22677
22307
|
// src/constants.ts
|
|
22678
22308
|
import { PublicKey, LAMPORTS_PER_SOL } from "@solana/web3.js";
|
|
22679
|
-
var
|
|
22309
|
+
var ER_VALIDATOR_DEVNET = new PublicKey("FnE6VJT5QNZdedZPnCoLsARgBwoE6DeJNjBs2H1gySXA");
|
|
22310
|
+
var ER_VALIDATOR_MAINNET = new PublicKey("MTEWGuqxUpYZGFJQcp8tLN7x5v9BSeoFHYWQQ3n3xzo");
|
|
22311
|
+
var ER_VALIDATOR = ER_VALIDATOR_DEVNET;
|
|
22312
|
+
function getErValidatorForSolanaEnv(env) {
|
|
22313
|
+
return env === "mainnet" ? ER_VALIDATOR_MAINNET : ER_VALIDATOR_DEVNET;
|
|
22314
|
+
}
|
|
22315
|
+
function getErValidatorForRpcEndpoint(rpcEndpoint) {
|
|
22316
|
+
return rpcEndpoint.includes("mainnet-tee") ? ER_VALIDATOR_MAINNET : ER_VALIDATOR_DEVNET;
|
|
22317
|
+
}
|
|
22680
22318
|
var PROGRAM_ID = new PublicKey("97FzQdWi26mFNR21AbQNg4KqofiCLqQydQfAvRQMcXhV");
|
|
22681
22319
|
var DELEGATION_PROGRAM_ID = new PublicKey("DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh");
|
|
22682
22320
|
var PERMISSION_PROGRAM_ID = new PublicKey("ACLseoPoyC3cBqoUtkbjZ4aDrkurZW86v19pXz2XQnp1");
|
|
22683
22321
|
var MAGIC_PROGRAM_ID = new PublicKey("Magic11111111111111111111111111111111111111");
|
|
22684
22322
|
var MAGIC_CONTEXT_ID = new PublicKey("MagicContext1111111111111111111111111111111");
|
|
22685
|
-
var DEPOSIT_SEED = "
|
|
22323
|
+
var DEPOSIT_SEED = "deposit_v2";
|
|
22686
22324
|
var DEPOSIT_SEED_BYTES = Buffer.from(DEPOSIT_SEED);
|
|
22687
22325
|
var USERNAME_DEPOSIT_SEED = "username_deposit";
|
|
22688
22326
|
var USERNAME_DEPOSIT_SEED_BYTES = Buffer.from(USERNAME_DEPOSIT_SEED);
|
|
@@ -22800,9 +22438,6 @@ function prettyStringify(obj) {
|
|
|
22800
22438
|
return `[${items.join(", ")}]`;
|
|
22801
22439
|
});
|
|
22802
22440
|
}
|
|
22803
|
-
function createProgram(provider) {
|
|
22804
|
-
return new Program(telegram_private_transfer_default, provider);
|
|
22805
|
-
}
|
|
22806
22441
|
function programFromRpc(signer, commitment, rpcEndpoint, wsEndpoint) {
|
|
22807
22442
|
const adapter = InternalWalletAdapter.from(signer);
|
|
22808
22443
|
const baseConnection = new Connection(rpcEndpoint, {
|
|
@@ -22812,7 +22447,7 @@ function programFromRpc(signer, commitment, rpcEndpoint, wsEndpoint) {
|
|
|
22812
22447
|
const baseProvider = new AnchorProvider(baseConnection, adapter, {
|
|
22813
22448
|
commitment
|
|
22814
22449
|
});
|
|
22815
|
-
return
|
|
22450
|
+
return new Program(telegram_private_transfer_default, baseProvider);
|
|
22816
22451
|
}
|
|
22817
22452
|
function deriveMessageSigner(signer) {
|
|
22818
22453
|
if (isKeypair(signer)) {
|
|
@@ -22876,6 +22511,15 @@ class LoyalPrivateTransactionsClient {
|
|
|
22876
22511
|
this.ephemeralProgram = ephemeralProgram;
|
|
22877
22512
|
this.wallet = wallet;
|
|
22878
22513
|
}
|
|
22514
|
+
getExpectedErValidator() {
|
|
22515
|
+
return getErValidatorForRpcEndpoint(this.ephemeralProgram.provider.connection.rpcEndpoint);
|
|
22516
|
+
}
|
|
22517
|
+
getExpectedValidator() {
|
|
22518
|
+
return this.getExpectedErValidator();
|
|
22519
|
+
}
|
|
22520
|
+
async getAccountDelegationStatus(account) {
|
|
22521
|
+
return this.getDelegationStatus(account);
|
|
22522
|
+
}
|
|
22879
22523
|
static async fromConfig(config) {
|
|
22880
22524
|
const {
|
|
22881
22525
|
signer,
|
|
@@ -22979,60 +22623,6 @@ class LoyalPrivateTransactionsClient {
|
|
|
22979
22623
|
}
|
|
22980
22624
|
return { signature, deposit };
|
|
22981
22625
|
}
|
|
22982
|
-
async depositForUsername(params) {
|
|
22983
|
-
const {
|
|
22984
|
-
username,
|
|
22985
|
-
tokenMint,
|
|
22986
|
-
amount,
|
|
22987
|
-
depositor,
|
|
22988
|
-
payer,
|
|
22989
|
-
depositorTokenAccount,
|
|
22990
|
-
rpcOptions
|
|
22991
|
-
} = params;
|
|
22992
|
-
this.validateUsername(username);
|
|
22993
|
-
const [depositPda] = findUsernameDepositPda(username, tokenMint);
|
|
22994
|
-
await this.ensureDelegated(depositPda, "depositForUsername-depositPda");
|
|
22995
|
-
const [vaultPda] = findVaultPda(tokenMint);
|
|
22996
|
-
const vaultTokenAccount = getAssociatedTokenAddressSync(tokenMint, vaultPda, true, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
22997
|
-
const signature = await this.ephemeralProgram.methods.depositForUsername(username, new BN(amount.toString())).accountsPartial({
|
|
22998
|
-
payer,
|
|
22999
|
-
depositor,
|
|
23000
|
-
deposit: depositPda,
|
|
23001
|
-
vault: vaultPda,
|
|
23002
|
-
vaultTokenAccount,
|
|
23003
|
-
depositorTokenAccount,
|
|
23004
|
-
tokenMint,
|
|
23005
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
23006
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
23007
|
-
systemProgram: SystemProgram.programId
|
|
23008
|
-
}).rpc(rpcOptions);
|
|
23009
|
-
return signature;
|
|
23010
|
-
}
|
|
23011
|
-
async claimUsernameDeposit(params) {
|
|
23012
|
-
const {
|
|
23013
|
-
username,
|
|
23014
|
-
tokenMint,
|
|
23015
|
-
amount,
|
|
23016
|
-
recipientTokenAccount,
|
|
23017
|
-
session,
|
|
23018
|
-
rpcOptions
|
|
23019
|
-
} = params;
|
|
23020
|
-
this.validateUsername(username);
|
|
23021
|
-
const [depositPda] = findUsernameDepositPda(username, tokenMint);
|
|
23022
|
-
await this.ensureDelegated(depositPda, "claimUsernameDeposit-depositPda");
|
|
23023
|
-
const [vaultPda] = findVaultPda(tokenMint);
|
|
23024
|
-
const vaultTokenAccount = getAssociatedTokenAddressSync(tokenMint, vaultPda, true, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
23025
|
-
const signature = await this.ephemeralProgram.methods.claimUsernameDeposit(new BN(amount.toString())).accountsPartial({
|
|
23026
|
-
recipientTokenAccount,
|
|
23027
|
-
vault: vaultPda,
|
|
23028
|
-
vaultTokenAccount,
|
|
23029
|
-
deposit: depositPda,
|
|
23030
|
-
tokenMint,
|
|
23031
|
-
session,
|
|
23032
|
-
tokenProgram: TOKEN_PROGRAM_ID
|
|
23033
|
-
}).rpc(rpcOptions);
|
|
23034
|
-
return signature;
|
|
23035
|
-
}
|
|
23036
22626
|
async claimUsernameDepositToDeposit(params) {
|
|
23037
22627
|
const { username, tokenMint, amount, recipient, session, rpcOptions } = params;
|
|
23038
22628
|
this.validateUsername(username);
|
|
@@ -23428,8 +23018,9 @@ class LoyalPrivateTransactionsClient {
|
|
|
23428
23018
|
console.error("/getDelegationStatus", JSON.stringify(delegationStatus, null, 2));
|
|
23429
23019
|
console.error("baseAccountInfo", prettyStringify(baseAccountInfo));
|
|
23430
23020
|
console.error("ephemeralAccountInfo", prettyStringify(ephemeralAccountInfo));
|
|
23021
|
+
const expectedValidator = this.getExpectedErValidator();
|
|
23431
23022
|
const authority = delegationStatus.result?.delegationRecord?.authority;
|
|
23432
|
-
if (authority && authority !==
|
|
23023
|
+
if (authority && authority !== expectedValidator.toString()) {
|
|
23433
23024
|
console.error(`Account is delegated on wrong validator: ${displayName}${account.toString()} - validator: ${authority}`);
|
|
23434
23025
|
}
|
|
23435
23026
|
throw new Error(`Account is delegated to ER: ${displayName}${account.toString()}`);
|
|
@@ -23451,7 +23042,7 @@ class LoyalPrivateTransactionsClient {
|
|
|
23451
23042
|
console.error("baseAccountInfo", prettyStringify(baseAccountInfo));
|
|
23452
23043
|
console.error("ephemeralAccountInfo", prettyStringify(ephemeralAccountInfo));
|
|
23453
23044
|
throw new Error(`Account is not delegated to ER: ${displayName}${account.toString()}`);
|
|
23454
|
-
} else if (!skipValidatorCheck && delegationStatus.result.delegationRecord.authority !==
|
|
23045
|
+
} else if (!skipValidatorCheck && delegationStatus.result.delegationRecord.authority !== this.getExpectedErValidator().toString()) {
|
|
23455
23046
|
console.error(`Account is delegated on wrong validator: ${displayName}${account.toString()} - validator: ${delegationStatus.result.delegationRecord.authority}`);
|
|
23456
23047
|
console.error("/getDelegationStatus:", JSON.stringify(delegationStatus, null, 2));
|
|
23457
23048
|
console.error("baseAccountInfo", prettyStringify(baseAccountInfo));
|
|
@@ -23471,8 +23062,11 @@ class LoyalPrivateTransactionsClient {
|
|
|
23471
23062
|
headers: { "Content-Type": "application/json" },
|
|
23472
23063
|
body
|
|
23473
23064
|
};
|
|
23065
|
+
const expectedValidator = this.getExpectedErValidator();
|
|
23066
|
+
const ephemeralUrl = this.ephemeralProgram.provider.connection.rpcEndpoint;
|
|
23067
|
+
const teeBaseUrl = ephemeralUrl.includes("mainnet-tee") ? "https://mainnet-tee.magicblock.app/" : "https://tee.magicblock.app/";
|
|
23474
23068
|
try {
|
|
23475
|
-
const teeRes = await fetch(
|
|
23069
|
+
const teeRes = await fetch(teeBaseUrl, options);
|
|
23476
23070
|
const teeData = await teeRes.json();
|
|
23477
23071
|
if (teeData.result?.isDelegated) {
|
|
23478
23072
|
return {
|
|
@@ -23480,23 +23074,24 @@ class LoyalPrivateTransactionsClient {
|
|
|
23480
23074
|
result: {
|
|
23481
23075
|
...teeData.result,
|
|
23482
23076
|
delegationRecord: {
|
|
23483
|
-
authority:
|
|
23077
|
+
authority: expectedValidator.toString()
|
|
23484
23078
|
}
|
|
23485
23079
|
}
|
|
23486
23080
|
};
|
|
23487
23081
|
}
|
|
23488
23082
|
} catch (e) {
|
|
23489
|
-
console.error("[getDelegationStatus] TEE fetch failed, falling back to devnet-router:", e);
|
|
23083
|
+
console.error("[getDelegationStatus] TEE fetch failed, falling back to devnet-router: Options:", options, "Error:", e);
|
|
23490
23084
|
}
|
|
23491
|
-
const
|
|
23085
|
+
const routerBaseUrl = ephemeralUrl.includes("mainnet-tee") ? "https://router.magicblock.app/" : "https://devnet-router.magicblock.app/";
|
|
23086
|
+
const res = await fetch(routerBaseUrl, options);
|
|
23492
23087
|
const routerData = await res.json();
|
|
23493
|
-
if (routerData.error?.message?.includes(
|
|
23088
|
+
if (routerData.error?.message?.includes(expectedValidator.toString())) {
|
|
23494
23089
|
return {
|
|
23495
23090
|
...routerData,
|
|
23496
23091
|
result: {
|
|
23497
23092
|
isDelegated: true,
|
|
23498
23093
|
delegationRecord: {
|
|
23499
|
-
authority:
|
|
23094
|
+
authority: expectedValidator.toString()
|
|
23500
23095
|
}
|
|
23501
23096
|
}
|
|
23502
23097
|
};
|
|
@@ -23513,6 +23108,8 @@ export {
|
|
|
23513
23108
|
isWalletLike,
|
|
23514
23109
|
isKeypair,
|
|
23515
23110
|
isAnchorProvider,
|
|
23111
|
+
getErValidatorForSolanaEnv,
|
|
23112
|
+
getErValidatorForRpcEndpoint,
|
|
23516
23113
|
findVaultPda,
|
|
23517
23114
|
findUsernameDepositPda,
|
|
23518
23115
|
findPermissionPda,
|
|
@@ -23533,6 +23130,8 @@ export {
|
|
|
23533
23130
|
LoyalPrivateTransactionsClient,
|
|
23534
23131
|
LAMPORTS_PER_SOL,
|
|
23535
23132
|
IDL,
|
|
23133
|
+
ER_VALIDATOR_MAINNET,
|
|
23134
|
+
ER_VALIDATOR_DEVNET,
|
|
23536
23135
|
ER_VALIDATOR,
|
|
23537
23136
|
DEPOSIT_SEED_BYTES,
|
|
23538
23137
|
DEPOSIT_SEED,
|