0xtrails 0.1.2 → 0.1.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/dist/analytics.d.ts +68 -1
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-BmFTEOaB.js → ccip-CWd4g9uZ.js} +1 -1
- package/dist/chains.d.ts +9 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/ens.d.ts +7 -0
- package/dist/ens.d.ts.map +1 -0
- package/dist/error.d.ts +2 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/{index-BPsVj7zK.js → index-BTUBzx4R.js} +23624 -21770
- package/dist/index.js +2 -2
- package/dist/lifi.d.ts +4 -0
- package/dist/lifi.d.ts.map +1 -0
- package/dist/mode.d.ts +1 -1
- package/dist/mode.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +3 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +2 -0
- package/dist/prices.d.ts.map +1 -1
- package/dist/relaySdk.d.ts.map +1 -1
- package/dist/relayer.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +3 -3
- package/dist/trails.d.ts.map +1 -1
- package/dist/transactions.d.ts.map +1 -1
- package/dist/wallets.d.ts +247 -5
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts +2 -0
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts +1 -0
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensDropdown.d.ts.map +1 -1
- package/dist/widget/components/FundSendForm.d.ts +2 -2
- package/dist/widget/components/FundSendForm.d.ts.map +1 -1
- package/dist/widget/components/PaySendForm.d.ts +2 -2
- package/dist/widget/components/PaySendForm.d.ts.map +1 -1
- package/dist/widget/components/QrCode.d.ts +1 -1
- package/dist/widget/components/QrCode.d.ts.map +1 -1
- package/dist/widget/components/RefundAddressInput.d.ts +13 -0
- package/dist/widget/components/RefundAddressInput.d.ts.map +1 -0
- package/dist/widget/components/Swap.d.ts +43 -0
- package/dist/widget/components/Swap.d.ts.map +1 -0
- package/dist/widget/components/TokenList.d.ts +0 -2
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts +26 -0
- package/dist/widget/components/TokenSelector.d.ts.map +1 -0
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletConnectionPending.d.ts +12 -0
- package/dist/widget/components/WalletConnectionPending.d.ts.map +1 -0
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/hooks/useAmountUsd.d.ts +1 -3
- package/dist/widget/hooks/useAmountUsd.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +6 -4
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +2 -3
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +9 -6
- package/src/aave.ts +13 -13
- package/src/analytics.ts +87 -4
- package/src/chains.ts +45 -7
- package/src/constants.ts +4 -4
- package/src/ens.ts +17 -0
- package/src/error.ts +16 -1
- package/src/lifi.ts +58 -0
- package/src/mode.ts +1 -1
- package/src/morpho.ts +3 -3
- package/src/pools.ts +18 -18
- package/src/prepareSend.ts +35 -3
- package/src/prices.ts +21 -0
- package/src/relaySdk.ts +1 -0
- package/src/relayer.ts +8 -0
- package/src/tokenBalances.ts +3 -0
- package/src/tokens.ts +85 -19
- package/src/trails.ts +2 -2
- package/src/transactions.ts +1 -0
- package/src/wallets.ts +275 -35
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/ChainFilterDropdown.tsx +42 -33
- package/src/widget/components/ChainImage.tsx +1 -1
- package/src/widget/components/ConnectWallet.tsx +92 -128
- package/src/widget/components/DebugScreensDropdown.tsx +3 -0
- package/src/widget/components/FundSendForm.tsx +17 -3
- package/src/widget/components/PaySendForm.tsx +16 -2
- package/src/widget/components/QRCodeDeposit.tsx +1 -1
- package/src/widget/components/QrCode.tsx +277 -16
- package/src/widget/components/Receipt.tsx +1 -1
- package/src/widget/components/RefundAddressInput.tsx +149 -0
- package/src/widget/components/Swap.tsx +648 -0
- package/src/widget/components/TokenList.tsx +27 -363
- package/src/widget/components/TokenSelector.tsx +405 -0
- package/src/widget/components/WalletConnect.tsx +9 -7
- package/src/widget/components/WalletConnectionPending.tsx +157 -0
- package/src/widget/components/WalletList.tsx +6 -5
- package/src/widget/hooks/useAmountUsd.ts +3 -8
- package/src/widget/hooks/useCheckout.ts +3 -2
- package/src/widget/hooks/useSendForm.ts +66 -32
- package/src/widget/hooks/useTokenList.ts +158 -106
- package/src/widget/widget.tsx +335 -72
package/src/analytics.ts
CHANGED
|
@@ -147,6 +147,8 @@ abstract class BaseAnalytics {
|
|
|
147
147
|
originTokenAddress?: string
|
|
148
148
|
destinationTokenAddress?: string
|
|
149
149
|
destinationTokenAmount?: string
|
|
150
|
+
mode?: string
|
|
151
|
+
fundMethod?: string
|
|
150
152
|
[key: string]: any
|
|
151
153
|
}) {
|
|
152
154
|
this.track({
|
|
@@ -170,6 +172,8 @@ abstract class BaseAnalytics {
|
|
|
170
172
|
trackPaymentCompleted(data: {
|
|
171
173
|
userAddress?: string
|
|
172
174
|
intentAddress?: string
|
|
175
|
+
mode?: string
|
|
176
|
+
fundMethod?: string
|
|
173
177
|
[key: string]: any
|
|
174
178
|
}) {
|
|
175
179
|
this.track({
|
|
@@ -193,6 +197,8 @@ abstract class BaseAnalytics {
|
|
|
193
197
|
error: string
|
|
194
198
|
userAddress?: string
|
|
195
199
|
intentAddress?: string
|
|
200
|
+
mode?: string
|
|
201
|
+
fundMethod?: string
|
|
196
202
|
[key: string]: any
|
|
197
203
|
}) {
|
|
198
204
|
this.track({
|
|
@@ -245,6 +251,8 @@ abstract class BaseAnalytics {
|
|
|
245
251
|
originTokenAddress?: string
|
|
246
252
|
destinationTokenAddress?: string
|
|
247
253
|
userAddress?: string
|
|
254
|
+
mode?: string
|
|
255
|
+
fundMethod?: string
|
|
248
256
|
[key: string]: any
|
|
249
257
|
}) {
|
|
250
258
|
this.track({
|
|
@@ -277,6 +285,8 @@ abstract class BaseAnalytics {
|
|
|
277
285
|
feeToken?: string
|
|
278
286
|
userAddress?: string
|
|
279
287
|
intentAddress?: string
|
|
288
|
+
mode?: string
|
|
289
|
+
fundMethod?: string
|
|
280
290
|
[key: string]: any
|
|
281
291
|
}) {
|
|
282
292
|
this.track({
|
|
@@ -314,6 +324,8 @@ abstract class BaseAnalytics {
|
|
|
314
324
|
destinationChainId?: number
|
|
315
325
|
originTokenAddress?: string
|
|
316
326
|
destinationTokenAddress?: string
|
|
327
|
+
mode?: string
|
|
328
|
+
fundMethod?: string
|
|
317
329
|
[key: string]: any
|
|
318
330
|
}) {
|
|
319
331
|
this.track({
|
|
@@ -376,6 +388,8 @@ abstract class BaseAnalytics {
|
|
|
376
388
|
intentAddress?: string
|
|
377
389
|
originChainId?: number
|
|
378
390
|
destinationChainId?: number
|
|
391
|
+
mode?: string
|
|
392
|
+
fundMethod?: string
|
|
379
393
|
[key: string]: any
|
|
380
394
|
}) {
|
|
381
395
|
this.track({
|
|
@@ -401,6 +415,8 @@ abstract class BaseAnalytics {
|
|
|
401
415
|
chainId: number
|
|
402
416
|
userAddress?: string
|
|
403
417
|
intentAddress?: string
|
|
418
|
+
mode?: string
|
|
419
|
+
fundMethod?: string
|
|
404
420
|
[key: string]: any
|
|
405
421
|
}) {
|
|
406
422
|
this.track({
|
|
@@ -423,6 +439,8 @@ abstract class BaseAnalytics {
|
|
|
423
439
|
transactionHash: string
|
|
424
440
|
userAddress?: string
|
|
425
441
|
intentAddress?: string
|
|
442
|
+
mode?: string
|
|
443
|
+
fundMethod?: string
|
|
426
444
|
[key: string]: any
|
|
427
445
|
}) {
|
|
428
446
|
this.track({
|
|
@@ -446,6 +464,8 @@ abstract class BaseAnalytics {
|
|
|
446
464
|
chainId: number
|
|
447
465
|
userAddress?: string
|
|
448
466
|
intentAddress?: string
|
|
467
|
+
mode?: string
|
|
468
|
+
fundMethod?: string
|
|
449
469
|
[key: string]: any
|
|
450
470
|
}) {
|
|
451
471
|
this.track({
|
|
@@ -470,6 +490,8 @@ abstract class BaseAnalytics {
|
|
|
470
490
|
blockNumber?: number
|
|
471
491
|
userAddress?: string
|
|
472
492
|
intentAddress?: string
|
|
493
|
+
mode?: string
|
|
494
|
+
fundMethod?: string
|
|
473
495
|
[key: string]: any
|
|
474
496
|
}) {
|
|
475
497
|
this.track({
|
|
@@ -495,6 +517,8 @@ abstract class BaseAnalytics {
|
|
|
495
517
|
error: string
|
|
496
518
|
userAddress?: string
|
|
497
519
|
intentAddress?: string
|
|
520
|
+
mode?: string
|
|
521
|
+
fundMethod?: string
|
|
498
522
|
[key: string]: any
|
|
499
523
|
}) {
|
|
500
524
|
this.track({
|
|
@@ -518,6 +542,8 @@ abstract class BaseAnalytics {
|
|
|
518
542
|
walletAddress?: string
|
|
519
543
|
contractAddress?: string
|
|
520
544
|
chainId?: number
|
|
545
|
+
mode?: string
|
|
546
|
+
fundMethod?: string
|
|
521
547
|
[key: string]: any
|
|
522
548
|
}) {
|
|
523
549
|
this.track({
|
|
@@ -540,6 +566,8 @@ abstract class BaseAnalytics {
|
|
|
540
566
|
walletAddress?: string
|
|
541
567
|
contractAddress?: string
|
|
542
568
|
chainId?: number
|
|
569
|
+
mode?: string
|
|
570
|
+
fundMethod?: string
|
|
543
571
|
[key: string]: any
|
|
544
572
|
}) {
|
|
545
573
|
this.track({
|
|
@@ -563,6 +591,8 @@ abstract class BaseAnalytics {
|
|
|
563
591
|
walletAddress?: string
|
|
564
592
|
contractAddress?: string
|
|
565
593
|
chainId?: number
|
|
594
|
+
mode?: string
|
|
595
|
+
fundMethod?: string
|
|
566
596
|
[key: string]: any
|
|
567
597
|
}) {
|
|
568
598
|
this.track({
|
|
@@ -623,6 +653,10 @@ class Analytics extends BaseAnalytics {
|
|
|
623
653
|
console.log("[trails-sdk] Analytics track:", event)
|
|
624
654
|
}
|
|
625
655
|
}
|
|
656
|
+
|
|
657
|
+
getSessionId() {
|
|
658
|
+
return this.databeat.getSessionId()
|
|
659
|
+
}
|
|
626
660
|
}
|
|
627
661
|
|
|
628
662
|
class MockAnalytics extends BaseAnalytics {
|
|
@@ -633,8 +667,7 @@ class MockAnalytics extends BaseAnalytics {
|
|
|
633
667
|
this.loggingEnabled = loggingEnabled
|
|
634
668
|
}
|
|
635
669
|
|
|
636
|
-
identifyUser(
|
|
637
|
-
console.log("[trails-sdk] MockAnalytics identifyUser:", address)
|
|
670
|
+
identifyUser(_data: { address: string }) {
|
|
638
671
|
return this
|
|
639
672
|
}
|
|
640
673
|
|
|
@@ -664,11 +697,19 @@ class MockAnalytics extends BaseAnalytics {
|
|
|
664
697
|
console.log("[trails-sdk] MockAnalytics track:", event)
|
|
665
698
|
}
|
|
666
699
|
}
|
|
700
|
+
|
|
701
|
+
getSessionId() {
|
|
702
|
+
return `0x${Math.random().toString(16).slice(2, 10)}`
|
|
703
|
+
}
|
|
667
704
|
}
|
|
668
705
|
|
|
669
|
-
let singleton: Analytics | null = null
|
|
706
|
+
let singleton: Analytics | MockAnalytics | null = null
|
|
670
707
|
|
|
671
708
|
export const getAnalytics = () => {
|
|
709
|
+
if (singleton) {
|
|
710
|
+
return singleton
|
|
711
|
+
}
|
|
712
|
+
|
|
672
713
|
const debugMode = getQueryParam("analyticsDebug") === "true"
|
|
673
714
|
let isLocalhost = true
|
|
674
715
|
if (typeof window !== "undefined") {
|
|
@@ -678,13 +719,16 @@ export const getAnalytics = () => {
|
|
|
678
719
|
}
|
|
679
720
|
const enableMockAnalytics = !DATABEAT_KEY || debugMode || isLocalhost
|
|
680
721
|
if (enableMockAnalytics) {
|
|
681
|
-
|
|
722
|
+
singleton = new MockAnalytics({ loggingEnabled: true }) // return a dummy analytics object
|
|
682
723
|
}
|
|
683
724
|
if (!singleton) {
|
|
684
725
|
singleton = new Analytics(DATABEAT_SERVER, {
|
|
685
726
|
jwt: DATABEAT_KEY,
|
|
686
727
|
})
|
|
687
728
|
}
|
|
729
|
+
|
|
730
|
+
console.log("[trails-sdk] Analytics sessionId:", singleton.getSessionId())
|
|
731
|
+
|
|
688
732
|
return singleton
|
|
689
733
|
}
|
|
690
734
|
|
|
@@ -723,6 +767,8 @@ export const trackPaymentStarted = (data: {
|
|
|
723
767
|
originTokenAddress?: string
|
|
724
768
|
destinationTokenAddress?: string
|
|
725
769
|
destinationTokenAmount?: string
|
|
770
|
+
mode?: string
|
|
771
|
+
fundMethod?: string
|
|
726
772
|
[key: string]: any
|
|
727
773
|
}) => {
|
|
728
774
|
const analytics = getAnalytics()
|
|
@@ -732,6 +778,8 @@ export const trackPaymentStarted = (data: {
|
|
|
732
778
|
export const trackPaymentCompleted = (data: {
|
|
733
779
|
userAddress?: string
|
|
734
780
|
intentAddress?: string
|
|
781
|
+
mode?: string
|
|
782
|
+
fundMethod?: string
|
|
735
783
|
[key: string]: any
|
|
736
784
|
}) => {
|
|
737
785
|
const analytics = getAnalytics()
|
|
@@ -742,6 +790,8 @@ export const trackPaymentError = (data: {
|
|
|
742
790
|
error: string
|
|
743
791
|
userAddress?: string
|
|
744
792
|
intentAddress?: string
|
|
793
|
+
mode?: string
|
|
794
|
+
fundMethod?: string
|
|
745
795
|
[key: string]: any
|
|
746
796
|
}) => {
|
|
747
797
|
const analytics = getAnalytics()
|
|
@@ -772,6 +822,8 @@ export const trackIntentQuoteRequested = (data: {
|
|
|
772
822
|
destinationChainId: number
|
|
773
823
|
tokenAddress?: string
|
|
774
824
|
userAddress?: string
|
|
825
|
+
mode?: string
|
|
826
|
+
fundMethod?: string
|
|
775
827
|
[key: string]: any
|
|
776
828
|
}) => {
|
|
777
829
|
const analytics = getAnalytics()
|
|
@@ -793,6 +845,8 @@ export const trackIntentQuoteReceived = (data: {
|
|
|
793
845
|
feeToken?: string
|
|
794
846
|
userAddress?: string
|
|
795
847
|
intentAddress?: string
|
|
848
|
+
mode?: string
|
|
849
|
+
fundMethod?: string
|
|
796
850
|
[key: string]: any
|
|
797
851
|
}) => {
|
|
798
852
|
const analytics = getAnalytics()
|
|
@@ -806,6 +860,8 @@ export const trackIntentQuoteError = (data: {
|
|
|
806
860
|
destinationChainId?: number
|
|
807
861
|
originTokenAddress?: string
|
|
808
862
|
destinationTokenAddress?: string
|
|
863
|
+
mode?: string
|
|
864
|
+
fundMethod?: string
|
|
809
865
|
[key: string]: any
|
|
810
866
|
}) => {
|
|
811
867
|
const analytics = getAnalytics()
|
|
@@ -817,6 +873,8 @@ export const trackIntentCommitStarted = (data: {
|
|
|
817
873
|
userAddress?: string
|
|
818
874
|
originChainId?: number
|
|
819
875
|
destinationChainId?: number
|
|
876
|
+
mode?: string
|
|
877
|
+
fundMethod?: string
|
|
820
878
|
[key: string]: any
|
|
821
879
|
}) => {
|
|
822
880
|
const analytics = getAnalytics()
|
|
@@ -828,6 +886,8 @@ export const trackIntentCommitCompleted = (data: {
|
|
|
828
886
|
userAddress?: string
|
|
829
887
|
originChainId?: number
|
|
830
888
|
destinationChainId?: number
|
|
889
|
+
mode?: string
|
|
890
|
+
fundMethod?: string
|
|
831
891
|
[key: string]: any
|
|
832
892
|
}) => {
|
|
833
893
|
const analytics = getAnalytics()
|
|
@@ -840,6 +900,8 @@ export const trackIntentCommitError = (data: {
|
|
|
840
900
|
intentAddress?: string
|
|
841
901
|
originChainId?: number
|
|
842
902
|
destinationChainId?: number
|
|
903
|
+
mode?: string
|
|
904
|
+
fundMethod?: string
|
|
843
905
|
[key: string]: any
|
|
844
906
|
}) => {
|
|
845
907
|
const analytics = getAnalytics()
|
|
@@ -852,6 +914,8 @@ export const trackTransactionStarted = (data: {
|
|
|
852
914
|
chainId: number
|
|
853
915
|
userAddress?: string
|
|
854
916
|
intentAddress?: string
|
|
917
|
+
mode?: string
|
|
918
|
+
fundMethod?: string
|
|
855
919
|
[key: string]: any
|
|
856
920
|
}) => {
|
|
857
921
|
const analytics = getAnalytics()
|
|
@@ -862,6 +926,8 @@ export const trackTransactionSigned = (data: {
|
|
|
862
926
|
transactionHash: string
|
|
863
927
|
userAddress?: string
|
|
864
928
|
intentAddress?: string
|
|
929
|
+
mode?: string
|
|
930
|
+
fundMethod?: string
|
|
865
931
|
[key: string]: any
|
|
866
932
|
}) => {
|
|
867
933
|
const analytics = getAnalytics()
|
|
@@ -873,6 +939,8 @@ export const trackTransactionSubmitted = (data: {
|
|
|
873
939
|
chainId: number
|
|
874
940
|
userAddress?: string
|
|
875
941
|
intentAddress?: string
|
|
942
|
+
mode?: string
|
|
943
|
+
fundMethod?: string
|
|
876
944
|
[key: string]: any
|
|
877
945
|
}) => {
|
|
878
946
|
const analytics = getAnalytics()
|
|
@@ -884,6 +952,8 @@ export const trackTransactionConfirmed = (data: {
|
|
|
884
952
|
blockNumber?: number
|
|
885
953
|
userAddress?: string
|
|
886
954
|
intentAddress?: string
|
|
955
|
+
mode?: string
|
|
956
|
+
fundMethod?: string
|
|
887
957
|
[key: string]: any
|
|
888
958
|
}) => {
|
|
889
959
|
const analytics = getAnalytics()
|
|
@@ -895,6 +965,8 @@ export const trackTransactionError = (data: {
|
|
|
895
965
|
error: string
|
|
896
966
|
userAddress?: string
|
|
897
967
|
intentAddress?: string
|
|
968
|
+
mode?: string
|
|
969
|
+
fundMethod?: string
|
|
898
970
|
[key: string]: any
|
|
899
971
|
}) => {
|
|
900
972
|
const analytics = getAnalytics()
|
|
@@ -906,6 +978,8 @@ export const trackRelayerCallStarted = (data: {
|
|
|
906
978
|
walletAddress?: string
|
|
907
979
|
contractAddress?: string
|
|
908
980
|
chainId?: number
|
|
981
|
+
mode?: string
|
|
982
|
+
fundMethod?: string
|
|
909
983
|
[key: string]: any
|
|
910
984
|
}) => {
|
|
911
985
|
const analytics = getAnalytics()
|
|
@@ -916,6 +990,8 @@ export const trackRelayerCallCompleted = (data: {
|
|
|
916
990
|
walletAddress?: string
|
|
917
991
|
contractAddress?: string
|
|
918
992
|
chainId?: number
|
|
993
|
+
mode?: string
|
|
994
|
+
fundMethod?: string
|
|
919
995
|
[key: string]: any
|
|
920
996
|
}) => {
|
|
921
997
|
const analytics = getAnalytics()
|
|
@@ -927,8 +1003,15 @@ export const trackRelayerCallError = (data: {
|
|
|
927
1003
|
walletAddress?: string
|
|
928
1004
|
contractAddress?: string
|
|
929
1005
|
chainId?: number
|
|
1006
|
+
mode?: string
|
|
1007
|
+
fundMethod?: string
|
|
930
1008
|
[key: string]: any
|
|
931
1009
|
}) => {
|
|
932
1010
|
const analytics = getAnalytics()
|
|
933
1011
|
analytics.trackRelayerCallError(data)
|
|
934
1012
|
}
|
|
1013
|
+
|
|
1014
|
+
export function getSessionId() {
|
|
1015
|
+
const analytics = getAnalytics()
|
|
1016
|
+
return analytics.getSessionId()
|
|
1017
|
+
}
|
package/src/chains.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { useQuery } from "@tanstack/react-query"
|
|
|
2
2
|
import type { Chain } from "viem"
|
|
3
3
|
import * as chains from "viem/chains"
|
|
4
4
|
import { getRelaySupportedChains } from "./relaySdk.js"
|
|
5
|
+
import { getLifiSupportedChains } from "./lifi.js"
|
|
5
6
|
import { getRpcSequenceProjectAccessKey } from "./config.js"
|
|
7
|
+
import type { QuoteProvider } from "./intents.js"
|
|
6
8
|
|
|
7
9
|
export const sequenceRpcUrls: Record<number, string> = {
|
|
8
10
|
[chains.arbitrum.id]: "https://nodes.sequence.app/arbitrum",
|
|
@@ -19,6 +21,8 @@ export const sequenceRpcUrls: Record<number, string> = {
|
|
|
19
21
|
[chains.b3.id]: "https://nodes.sequence.app/b3",
|
|
20
22
|
[chains.blast.id]: "https://nodes.sequence.app/blast",
|
|
21
23
|
[chains.bsc.id]: "https://nodes.sequence.app/bsc",
|
|
24
|
+
[chains.katana.id]: "https://nodes.sequence.app/katana",
|
|
25
|
+
[chains.etherlink.id]: "https://nodes.sequence.app/etherlink",
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
export const getRpcUrl = (
|
|
@@ -46,6 +50,8 @@ export const supportedSequenceChains: Record<number, Chain> = {
|
|
|
46
50
|
[chains.polygon.id]: getChainInfo(chains.polygon.id)!,
|
|
47
51
|
[chains.soneium.id]: getChainInfo(chains.soneium.id)!,
|
|
48
52
|
[chains.xai.id]: getChainInfo(chains.xai.id)!,
|
|
53
|
+
[chains.katana.id]: getChainInfo(chains.katana.id)!,
|
|
54
|
+
[chains.etherlink.id]: getChainInfo(chains.etherlink.id)!,
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
export const supportedSequenceTestnetChains: Record<number, Chain> = {
|
|
@@ -61,6 +67,7 @@ export const supportedSequenceTestnetChains: Record<number, Chain> = {
|
|
|
61
67
|
[chains.optimismSepolia.id]: getChainInfo(chains.optimismSepolia.id)!,
|
|
62
68
|
[chains.soneiumMinato.id]: getChainInfo(chains.soneiumMinato.id)!,
|
|
63
69
|
[chains.xaiTestnet.id]: getChainInfo(chains.xaiTestnet.id)!,
|
|
70
|
+
[chains.etherlinkTestnet.id]: getChainInfo(chains.etherlinkTestnet.id)!,
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
export const mainnetChainsToTestnetChains: Record<number, Chain> = {
|
|
@@ -78,13 +85,15 @@ export const mainnetChainsToTestnetChains: Record<number, Chain> = {
|
|
|
78
85
|
[chains.bsc.id]: chains.bscTestnet,
|
|
79
86
|
[chains.arbitrumNova.id]: chains.arbitrumSepolia,
|
|
80
87
|
[chains.apeChain.id]: chains.sepolia,
|
|
88
|
+
[chains.etherlink.id]: chains.etherlinkTestnet,
|
|
81
89
|
}
|
|
82
90
|
|
|
83
91
|
// Helper to get chain info
|
|
84
92
|
export function getChainInfo(
|
|
85
|
-
chainId
|
|
93
|
+
chainId?: number,
|
|
86
94
|
options?: { usePublicRpc?: boolean },
|
|
87
95
|
): Chain | null {
|
|
96
|
+
if (!chainId) return null
|
|
88
97
|
const chainInfo =
|
|
89
98
|
(Object.values(chains) as Array<Chain>).find(
|
|
90
99
|
(chain: Chain) => chain.id === chainId,
|
|
@@ -155,13 +164,36 @@ function sortChains(chainList: Chain[]): Chain[] {
|
|
|
155
164
|
})
|
|
156
165
|
}
|
|
157
166
|
|
|
158
|
-
export async function
|
|
159
|
-
const sequenceChains = await getSupportedSequenceChains()
|
|
167
|
+
export async function getAllQuoteProviderChains(): Promise<Chain[]> {
|
|
160
168
|
const relayChains = await getRelaySupportedChains()
|
|
169
|
+
const lifiChains = await getLifiSupportedChains()
|
|
170
|
+
const allChains = [...relayChains, ...lifiChains]
|
|
171
|
+
return allChains.filter(
|
|
172
|
+
(chain, index, self) => index === self.findIndex((c) => c.id === chain.id),
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export async function getSupportedChains({
|
|
177
|
+
quoteProvider,
|
|
178
|
+
}: {
|
|
179
|
+
quoteProvider?: QuoteProvider | string
|
|
180
|
+
} = {}): Promise<Chain[]> {
|
|
181
|
+
let quoteProviderChains: Chain[] = []
|
|
182
|
+
if (quoteProvider === "relay") {
|
|
183
|
+
quoteProviderChains = await getRelaySupportedChains()
|
|
184
|
+
} else if (quoteProvider === "lifi") {
|
|
185
|
+
quoteProviderChains = await getLifiSupportedChains()
|
|
186
|
+
} else {
|
|
187
|
+
quoteProviderChains = await getAllQuoteProviderChains()
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const sequenceChains = await getSupportedSequenceChains()
|
|
161
191
|
|
|
162
192
|
// Find intersection of sequence chains and relay chains
|
|
163
193
|
const supportedChains = sequenceChains.filter((sequenceChain) =>
|
|
164
|
-
|
|
194
|
+
quoteProviderChains.some(
|
|
195
|
+
(quoteProviderChain) => quoteProviderChain.id === sequenceChain.id,
|
|
196
|
+
),
|
|
165
197
|
)
|
|
166
198
|
|
|
167
199
|
// Ensure unique chain IDs by filtering duplicates
|
|
@@ -169,17 +201,23 @@ export async function getSupportedChains(): Promise<Chain[]> {
|
|
|
169
201
|
(chain, index, self) => index === self.findIndex((c) => c.id === chain.id),
|
|
170
202
|
)
|
|
171
203
|
|
|
204
|
+
const sortedChains = sortChains(uniqueChains)
|
|
205
|
+
|
|
172
206
|
// Sort chains by priority and then by name
|
|
173
|
-
return
|
|
207
|
+
return sortedChains
|
|
174
208
|
}
|
|
175
209
|
|
|
176
|
-
export function useSupportedChains(
|
|
210
|
+
export function useSupportedChains({
|
|
211
|
+
quoteProvider,
|
|
212
|
+
}: {
|
|
213
|
+
quoteProvider?: QuoteProvider | string
|
|
214
|
+
} = {}): {
|
|
177
215
|
supportedChains: Chain[]
|
|
178
216
|
isLoadingChains: boolean
|
|
179
217
|
} {
|
|
180
218
|
const { data: supportedChains = [], isLoading: isLoadingChains } = useQuery({
|
|
181
219
|
queryKey: ["supportedChains"],
|
|
182
|
-
queryFn: getSupportedChains,
|
|
220
|
+
queryFn: () => getSupportedChains({ quoteProvider }),
|
|
183
221
|
staleTime: 60 * 60 * 1000, // 1 hour - chains rarely change
|
|
184
222
|
gcTime: 24 * 60 * 60 * 1000, // 24 hours - keep in cache for a full day
|
|
185
223
|
refetchOnWindowFocus: false, // Don't refetch when window regains focus
|
package/src/constants.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Context as ContextLike } from "@0xsequence/wallet-primitives"
|
|
2
2
|
|
|
3
3
|
export const SEQUENCE_V3_CONTRACT_ADDRESSES: ContextLike.Context = {
|
|
4
|
-
factory: "
|
|
5
|
-
stage1: "
|
|
6
|
-
stage2: "
|
|
4
|
+
factory: "0x7aaaD48b90Ea2c1DaE03cb68ea1Ed8E1DD26dB38" as `0x${string}`,
|
|
5
|
+
stage1: "0x4d7c112790F03caFc7287b1a29Aa03da1Bb00C10" as `0x${string}`,
|
|
6
|
+
stage2: "0x7C96ff440BCE51EEF0C9f748D69246B4b3F28173" as `0x${string}`,
|
|
7
7
|
creationCode:
|
|
8
|
-
"
|
|
8
|
+
"0x6041600e3d396021805130553df33d3d36153402601f57363d3d373d363d30545af43d82803e903d91601f57fd5bf3" as `0x${string}`,
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const ATTESATION_SIGNER_ADDRESS =
|
package/src/ens.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { mainnet } from "viem/chains"
|
|
2
|
+
import { useEnsAddress } from "wagmi"
|
|
3
|
+
|
|
4
|
+
export function useResolveEnsAddress({ textInput }: { textInput: string }) {
|
|
5
|
+
const { data: ensAddress, isLoading } = useEnsAddress({
|
|
6
|
+
name: textInput?.endsWith(".eth") ? textInput : undefined,
|
|
7
|
+
chainId: mainnet.id,
|
|
8
|
+
query: {
|
|
9
|
+
enabled: !!textInput && textInput.endsWith(".eth"),
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
ensAddress,
|
|
15
|
+
isLoading,
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/error.ts
CHANGED
|
@@ -3,7 +3,10 @@ export function getFullErrorMessage(err: any) {
|
|
|
3
3
|
|
|
4
4
|
let current = err
|
|
5
5
|
while (current) {
|
|
6
|
-
if (current
|
|
6
|
+
if (typeof current === "string") {
|
|
7
|
+
messages.push(current)
|
|
8
|
+
}
|
|
9
|
+
if (typeof current.message === "string") {
|
|
7
10
|
messages.push(current.message)
|
|
8
11
|
}
|
|
9
12
|
|
|
@@ -37,3 +40,15 @@ export class InsufficientBalanceError extends Error {
|
|
|
37
40
|
this.name = "InsufficientBalanceError"
|
|
38
41
|
}
|
|
39
42
|
}
|
|
43
|
+
|
|
44
|
+
export function getIsApiError(err: unknown) {
|
|
45
|
+
const isApiError = /request aborted/gi.test(getErrorString(err).toLowerCase())
|
|
46
|
+
return isApiError
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getIsRateLimitedError(err: unknown) {
|
|
50
|
+
const isRateLimited = /slow down|request rate|rate limit/gi.test(
|
|
51
|
+
getErrorString(err).toLowerCase(),
|
|
52
|
+
)
|
|
53
|
+
return isRateLimited
|
|
54
|
+
}
|
package/src/lifi.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as chains from "viem/chains"
|
|
2
|
+
import type { Chain } from "viem/chains"
|
|
3
|
+
|
|
4
|
+
export const lifiSupportedChains: Record<number, Chain> = {
|
|
5
|
+
[chains.mainnet.id]: chains.mainnet,
|
|
6
|
+
[chains.polygon.id]: chains.polygon,
|
|
7
|
+
[chains.arbitrum.id]: chains.arbitrum,
|
|
8
|
+
[chains.avalanche.id]: chains.avalanche,
|
|
9
|
+
[chains.optimism.id]: chains.optimism,
|
|
10
|
+
[chains.base.id]: chains.base,
|
|
11
|
+
[chains.bsc.id]: chains.bsc,
|
|
12
|
+
[chains.blast.id]: chains.blast,
|
|
13
|
+
[chains.gnosis.id]: chains.gnosis,
|
|
14
|
+
[chains.scroll.id]: chains.scroll,
|
|
15
|
+
[chains.linea.id]: chains.linea,
|
|
16
|
+
[chains.zksync.id]: chains.zksync,
|
|
17
|
+
[chains.polygonZkEvm.id]: chains.polygonZkEvm,
|
|
18
|
+
[chains.moonriver.id]: chains.moonriver,
|
|
19
|
+
[chains.fantom.id]: chains.fantom,
|
|
20
|
+
[chains.moonbeam.id]: chains.moonbeam,
|
|
21
|
+
[chains.fuse.id]: chains.fuse,
|
|
22
|
+
[chains.boba.id]: chains.boba,
|
|
23
|
+
[chains.metis.id]: chains.metis,
|
|
24
|
+
[chains.lisk.id]: chains.lisk,
|
|
25
|
+
[chains.unichain.id]: chains.unichain,
|
|
26
|
+
[chains.aurora.id]: chains.aurora,
|
|
27
|
+
[chains.sei.id]: chains.sei,
|
|
28
|
+
[chains.immutableZkEvm.id]: chains.immutableZkEvm,
|
|
29
|
+
[chains.flare.id]: chains.flare,
|
|
30
|
+
[chains.sonic.id]: chains.sonic,
|
|
31
|
+
[chains.gravity.id]: chains.gravity,
|
|
32
|
+
[chains.taiko.id]: chains.taiko,
|
|
33
|
+
[chains.soneium.id]: chains.soneium,
|
|
34
|
+
[chains.swellchain.id]: chains.swellchain,
|
|
35
|
+
[chains.opBNB.id]: chains.opBNB,
|
|
36
|
+
[chains.corn.id]: chains.corn,
|
|
37
|
+
[chains.lens.id]: chains.lens,
|
|
38
|
+
[chains.cronos.id]: chains.cronos,
|
|
39
|
+
[chains.abstract.id]: chains.abstract,
|
|
40
|
+
[chains.rootstock.id]: chains.rootstock,
|
|
41
|
+
[chains.apeChain.id]: chains.apeChain,
|
|
42
|
+
[chains.celo.id]: chains.celo,
|
|
43
|
+
[chains.worldchain.id]: chains.worldchain,
|
|
44
|
+
[chains.xdc.id]: chains.xdc,
|
|
45
|
+
[chains.mantle.id]: chains.mantle,
|
|
46
|
+
[chains.superposition.id]: chains.superposition,
|
|
47
|
+
[chains.ink.id]: chains.ink,
|
|
48
|
+
[chains.bob.id]: chains.bob,
|
|
49
|
+
[chains.berachain.id]: chains.berachain,
|
|
50
|
+
[chains.kaia.id]: chains.kaia,
|
|
51
|
+
[chains.plume.id]: chains.plume,
|
|
52
|
+
[chains.etherlink.id]: chains.etherlink,
|
|
53
|
+
[chains.katana.id]: chains.katana,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function getLifiSupportedChains(): Promise<Chain[]> {
|
|
57
|
+
return Object.values(lifiSupportedChains)
|
|
58
|
+
}
|
package/src/mode.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type Mode = "pay" | "fund" | "earn"
|
|
1
|
+
export type Mode = "pay" | "fund" | "earn" | "swap"
|
package/src/morpho.ts
CHANGED
|
@@ -303,9 +303,9 @@ function transformVaultToPool(vaultData: any): Pool | null {
|
|
|
303
303
|
const apyPercentage = apy * 100
|
|
304
304
|
|
|
305
305
|
if (tvlInMillions < 1 || apyPercentage > 20) {
|
|
306
|
-
console.log(
|
|
307
|
-
|
|
308
|
-
)
|
|
306
|
+
// console.log(
|
|
307
|
+
// `Filtering out vault ${vaultData.address}: TVL=${tvlInMillions.toFixed(2)}M, APY=${apyPercentage.toFixed(2)}%`,
|
|
308
|
+
// )
|
|
309
309
|
return null
|
|
310
310
|
}
|
|
311
311
|
|
package/src/pools.ts
CHANGED
|
@@ -128,24 +128,24 @@ export function usePools() {
|
|
|
128
128
|
}
|
|
129
129
|
}, [aaveError, morphoError])
|
|
130
130
|
|
|
131
|
-
console.log("[trails-sdk] === COMBINED POOLS DEBUG ===")
|
|
132
|
-
console.log("[trails-sdk] Cache valid:", isCacheValid)
|
|
133
|
-
console.log("[trails-sdk] Aave pools count:", aavePools?.length || 0)
|
|
134
|
-
console.log("[trails-sdk] Morpho pools count:", morphoPools?.length || 0)
|
|
135
|
-
console.log("[trails-sdk] Total pools count:", sortedPools.length)
|
|
136
|
-
console.log(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
console.log(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
)
|
|
148
|
-
console.log("[trails-sdk] ==============================")
|
|
131
|
+
// console.log("[trails-sdk] === COMBINED POOLS DEBUG ===")
|
|
132
|
+
// console.log("[trails-sdk] Cache valid:", isCacheValid)
|
|
133
|
+
// console.log("[trails-sdk] Aave pools count:", aavePools?.length || 0)
|
|
134
|
+
// console.log("[trails-sdk] Morpho pools count:", morphoPools?.length || 0)
|
|
135
|
+
// console.log("[trails-sdk] Total pools count:", sortedPools.length)
|
|
136
|
+
// console.log(
|
|
137
|
+
// "[trails-sdk] Loading states - Aave:",
|
|
138
|
+
// aaveLoading,
|
|
139
|
+
// "Morpho:",
|
|
140
|
+
// morphoLoading,
|
|
141
|
+
// )
|
|
142
|
+
// console.log(
|
|
143
|
+
// "[trails-sdk] Error states - Aave:",
|
|
144
|
+
// aaveError,
|
|
145
|
+
// "Morpho:",
|
|
146
|
+
// morphoError,
|
|
147
|
+
// )
|
|
148
|
+
// console.log("[trails-sdk] ==============================")
|
|
149
149
|
|
|
150
150
|
return {
|
|
151
151
|
data: sortedPools,
|