@funkit/api-base 1.4.2 → 1.5.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/CHANGELOG.md +23 -0
- package/dist/index.js +507 -61
- package/dist/index.js.map +4 -4
- package/dist/src/consts/api.d.ts +1 -0
- package/dist/src/consts/customers.d.ts +4 -0
- package/dist/src/consts/index.d.ts +1 -0
- package/dist/src/consts/retry.d.ts +2 -2
- package/dist/src/services/assets/endpoints.d.ts +19 -5
- package/dist/src/services/assets/types.d.ts +23 -0
- package/dist/src/services/checkout/types.d.ts +4 -3
- package/dist/src/services/faucet/endpoints.d.ts +1 -1
- package/dist/src/services/fw-access/endpoints.d.ts +3 -0
- package/dist/src/services/fw-access/index.d.ts +2 -0
- package/dist/src/services/fw-access/types.d.ts +10 -0
- package/dist/src/services/fw-group/endpoints.d.ts +2 -0
- package/dist/src/services/fw-group/index.d.ts +2 -0
- package/dist/src/services/fw-group/types.d.ts +13 -0
- package/dist/src/services/fw-info/endpoints.d.ts +3 -0
- package/dist/src/services/fw-info/index.d.ts +2 -0
- package/dist/src/services/fw-info/types.d.ts +21 -0
- package/dist/src/services/fw-operation/endpoints.d.ts +11 -0
- package/dist/src/services/fw-operation/index.d.ts +2 -0
- package/dist/src/services/fw-operation/types.d.ts +149 -0
- package/dist/src/services/fw-paymaster/endpoints.d.ts +2 -0
- package/dist/src/services/fw-paymaster/index.d.ts +2 -0
- package/dist/src/services/fw-paymaster/types.d.ts +24 -0
- package/dist/src/services/fw-user/endpoints.d.ts +10 -0
- package/dist/src/services/fw-user/index.d.ts +2 -0
- package/dist/src/services/fw-user/types.d.ts +36 -0
- package/dist/src/services/index.d.ts +6 -0
- package/dist/src/services/mesh/endpoints.d.ts +35 -2
- package/dist/src/services/mesh/types.d.ts +16 -1
- package/dist/src/utils/error.d.ts +2 -1
- package/dist/src/utils/request.d.ts +3 -3
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// src/consts/api.ts
|
|
2
|
-
var API_BASE_URL =
|
|
3
|
-
|
|
4
|
-
"https://api.fun.xyz/v1"
|
|
5
|
-
);
|
|
2
|
+
var API_BASE_URL = "https://api.fun.xyz/v1";
|
|
3
|
+
var MESH_API_BASE_URL = "https://frog.fun.xyz";
|
|
6
4
|
var FUN_FAUCET_URL = "https://api.fun.xyz/demo-faucet";
|
|
7
5
|
|
|
8
6
|
// src/utils/error.ts
|
|
@@ -33,6 +31,12 @@ var DEFAULT_RETRY_OPTIONS = {
|
|
|
33
31
|
calculateDelay: null
|
|
34
32
|
};
|
|
35
33
|
|
|
34
|
+
// src/consts/customers.ts
|
|
35
|
+
var DEGEN_API_KEY = "m4iHIILHcL4gN8EXCMzGe8zIdhuCXxck49mWajzJ";
|
|
36
|
+
var DYDX_API_KEY = "NJq0CGrsE19xBbP1vHyBOp8xJvzYo9kayJHqDFP5";
|
|
37
|
+
var POLYMARKET_API_KEY = "Y53dikxXdT4E3afI1l8BMBSWgyhKvf65k6Dut1k6";
|
|
38
|
+
var DEV_API_KEY = "Z9SZaOwpmE40KX61mUKWm5hrpGh7WHVkaTvQJpQk";
|
|
39
|
+
|
|
36
40
|
// src/utils/checkout.ts
|
|
37
41
|
import { toHex } from "viem";
|
|
38
42
|
function randomBytes(length) {
|
|
@@ -68,14 +72,14 @@ var stringifyWithBigIntSanitization = (object) => {
|
|
|
68
72
|
// return everything else unchanged
|
|
69
73
|
);
|
|
70
74
|
};
|
|
71
|
-
|
|
75
|
+
async function sendRequest({
|
|
72
76
|
uri,
|
|
73
77
|
method,
|
|
74
78
|
apiKey,
|
|
75
79
|
body = {},
|
|
76
80
|
retryOptions = {},
|
|
77
81
|
signal
|
|
78
|
-
})
|
|
82
|
+
}) {
|
|
79
83
|
try {
|
|
80
84
|
const headers = {
|
|
81
85
|
"Content-Type": "application/json",
|
|
@@ -142,7 +146,8 @@ var sendRequest = async ({
|
|
|
142
146
|
if (errorCode === ErrorCode.UserOpFailureError) {
|
|
143
147
|
throw new UserOpFailureError2(
|
|
144
148
|
ErrorCode.UserOpFailureError,
|
|
145
|
-
|
|
149
|
+
JSON.stringify(json),
|
|
150
|
+
// UserOpFailureError may JSON.parse this! Do not modify!
|
|
146
151
|
errorMsg,
|
|
147
152
|
{ body },
|
|
148
153
|
"fix user op failure. Most of the time this is due to invalid parameters",
|
|
@@ -190,7 +195,7 @@ var sendRequest = async ({
|
|
|
190
195
|
"https://docs.fun.xyz"
|
|
191
196
|
);
|
|
192
197
|
}
|
|
193
|
-
}
|
|
198
|
+
}
|
|
194
199
|
async function sendGetRequest({
|
|
195
200
|
uri,
|
|
196
201
|
apiKey,
|
|
@@ -265,6 +270,17 @@ async function getAssetPriceInfo({
|
|
|
265
270
|
});
|
|
266
271
|
return priceInfo;
|
|
267
272
|
}
|
|
273
|
+
async function getAssetErc20ByChainAndSymbol({
|
|
274
|
+
chainId,
|
|
275
|
+
symbol,
|
|
276
|
+
apiKey
|
|
277
|
+
}) {
|
|
278
|
+
return await sendGetRequest({
|
|
279
|
+
uri: `${API_BASE_URL}/asset/erc20/${chainId}/${symbol}`,
|
|
280
|
+
apiKey,
|
|
281
|
+
retryOptions: { maxAttempts: 2 }
|
|
282
|
+
});
|
|
283
|
+
}
|
|
268
284
|
async function getAllWalletTokens({
|
|
269
285
|
walletAddress,
|
|
270
286
|
onlyVerifiedTokens,
|
|
@@ -328,6 +344,25 @@ async function getWalletLidoWithdrawalsByChainId({
|
|
|
328
344
|
apiKey
|
|
329
345
|
});
|
|
330
346
|
}
|
|
347
|
+
async function getNftName({
|
|
348
|
+
chainId,
|
|
349
|
+
nftAddress,
|
|
350
|
+
apiKey
|
|
351
|
+
}) {
|
|
352
|
+
return await sendGetRequest({
|
|
353
|
+
uri: `${API_BASE_URL}/asset/nft/${chainId}/${nftAddress}`,
|
|
354
|
+
apiKey
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
async function getNftAddress({
|
|
358
|
+
name,
|
|
359
|
+
apiKey
|
|
360
|
+
}) {
|
|
361
|
+
return await sendGetRequest({
|
|
362
|
+
uri: `${API_BASE_URL}/asset/nft?name=${name}`,
|
|
363
|
+
apiKey
|
|
364
|
+
});
|
|
365
|
+
}
|
|
331
366
|
|
|
332
367
|
// src/services/checkout/endpoints.ts
|
|
333
368
|
import Big from "big.js";
|
|
@@ -416,7 +451,7 @@ async function getCheckoutQuote({
|
|
|
416
451
|
};
|
|
417
452
|
} catch (err) {
|
|
418
453
|
throw new Error(
|
|
419
|
-
`An error occured trying to generate a checkout quote: ${err.message}`
|
|
454
|
+
`An error occured trying to generate a checkout quote: ${err instanceof Error ? err.message : JSON.stringify(err)}`
|
|
420
455
|
);
|
|
421
456
|
}
|
|
422
457
|
}
|
|
@@ -587,27 +622,375 @@ async function getAssetFromFaucet({
|
|
|
587
622
|
});
|
|
588
623
|
}
|
|
589
624
|
|
|
625
|
+
// src/services/fw-access/endpoints.ts
|
|
626
|
+
async function initializeWalletAccess({
|
|
627
|
+
walletAddr,
|
|
628
|
+
creatorAddr,
|
|
629
|
+
apiKey
|
|
630
|
+
}) {
|
|
631
|
+
await sendPostRequest({
|
|
632
|
+
uri: `${API_BASE_URL}/access/wallet`,
|
|
633
|
+
body: { walletAddr, creatorAddr },
|
|
634
|
+
apiKey
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
async function checkWalletAccessInitialization({
|
|
638
|
+
walletAddr,
|
|
639
|
+
apiKey
|
|
640
|
+
}) {
|
|
641
|
+
return (await sendGetRequest({
|
|
642
|
+
uri: `${API_BASE_URL}/access/wallet/${walletAddr}`,
|
|
643
|
+
apiKey
|
|
644
|
+
})).initialized;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// src/services/fw-group/endpoints.ts
|
|
648
|
+
async function getGroups({
|
|
649
|
+
groupIds,
|
|
650
|
+
chainId,
|
|
651
|
+
apiKey
|
|
652
|
+
}) {
|
|
653
|
+
return (await sendPostRequest({
|
|
654
|
+
uri: `${API_BASE_URL}/group/get-groups`,
|
|
655
|
+
body: { groupIds, chainId },
|
|
656
|
+
apiKey
|
|
657
|
+
})).groups;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// src/services/fw-info/endpoints.ts
|
|
661
|
+
async function getChainFromId({
|
|
662
|
+
chainId,
|
|
663
|
+
apiKey
|
|
664
|
+
}) {
|
|
665
|
+
const res = await sendGetRequest({
|
|
666
|
+
uri: `${API_BASE_URL}/chain-info/${chainId}`,
|
|
667
|
+
apiKey
|
|
668
|
+
});
|
|
669
|
+
if (!res) {
|
|
670
|
+
throw new Error(JSON.stringify(res));
|
|
671
|
+
}
|
|
672
|
+
return res;
|
|
673
|
+
}
|
|
674
|
+
async function getChainFromName({
|
|
675
|
+
name,
|
|
676
|
+
apiKey
|
|
677
|
+
}) {
|
|
678
|
+
const res = await sendGetRequest({
|
|
679
|
+
uri: `${API_BASE_URL}/chain-info?name=${name}`,
|
|
680
|
+
apiKey
|
|
681
|
+
});
|
|
682
|
+
if (!res) {
|
|
683
|
+
throw new Error(JSON.stringify(res));
|
|
684
|
+
}
|
|
685
|
+
return res;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// src/services/fw-operation/endpoints.ts
|
|
689
|
+
async function createOp({
|
|
690
|
+
op,
|
|
691
|
+
apiKey
|
|
692
|
+
}) {
|
|
693
|
+
return (await sendPostRequest({
|
|
694
|
+
uri: `${API_BASE_URL}/operation`,
|
|
695
|
+
body: { ...op },
|
|
696
|
+
apiKey
|
|
697
|
+
})).opId;
|
|
698
|
+
}
|
|
699
|
+
async function getOpsOfWallet({
|
|
700
|
+
walletAddr,
|
|
701
|
+
chainId,
|
|
702
|
+
apiKey,
|
|
703
|
+
status
|
|
704
|
+
}) {
|
|
705
|
+
const endpoint = status ? `${API_BASE_URL}/operation/wallet/${walletAddr}/chain/${chainId}?status=${status}` : `${API_BASE_URL}/operation/wallet/${walletAddr}/chain/${chainId}`;
|
|
706
|
+
return (await sendGetRequest({ uri: endpoint, apiKey })).operations;
|
|
707
|
+
}
|
|
708
|
+
async function getOps({
|
|
709
|
+
opIds,
|
|
710
|
+
chainId,
|
|
711
|
+
apiKey
|
|
712
|
+
}) {
|
|
713
|
+
return (await sendPostRequest({
|
|
714
|
+
uri: `${API_BASE_URL}/operation/get-operations`,
|
|
715
|
+
body: {
|
|
716
|
+
opIds,
|
|
717
|
+
chainId
|
|
718
|
+
},
|
|
719
|
+
apiKey
|
|
720
|
+
})).operations;
|
|
721
|
+
}
|
|
722
|
+
async function deleteOp({
|
|
723
|
+
opId,
|
|
724
|
+
chainId,
|
|
725
|
+
apiKey
|
|
726
|
+
}) {
|
|
727
|
+
await sendDeleteRequest({
|
|
728
|
+
uri: `${API_BASE_URL}/operation/${opId}/chain/${chainId}`,
|
|
729
|
+
apiKey
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
async function signOp({
|
|
733
|
+
opId,
|
|
734
|
+
chainId,
|
|
735
|
+
signature,
|
|
736
|
+
signedBy,
|
|
737
|
+
apiKey,
|
|
738
|
+
threshold
|
|
739
|
+
}) {
|
|
740
|
+
await sendPostRequest({
|
|
741
|
+
uri: `${API_BASE_URL}/operation/sign`,
|
|
742
|
+
body: {
|
|
743
|
+
opId,
|
|
744
|
+
chainId,
|
|
745
|
+
signature,
|
|
746
|
+
signedBy,
|
|
747
|
+
threshold
|
|
748
|
+
},
|
|
749
|
+
apiKey
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
async function executeOp({
|
|
753
|
+
input,
|
|
754
|
+
apiKey
|
|
755
|
+
}) {
|
|
756
|
+
return await sendPostRequest({
|
|
757
|
+
uri: `${API_BASE_URL}/operation/execute`,
|
|
758
|
+
body: input,
|
|
759
|
+
apiKey
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
async function estimateOp({
|
|
763
|
+
apiKey,
|
|
764
|
+
input
|
|
765
|
+
}) {
|
|
766
|
+
return await sendPostRequest({
|
|
767
|
+
uri: `${API_BASE_URL}/operation/estimate`,
|
|
768
|
+
body: input,
|
|
769
|
+
apiKey
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
async function scheduleOp({
|
|
773
|
+
input,
|
|
774
|
+
apiKey
|
|
775
|
+
}) {
|
|
776
|
+
await sendPostRequest({
|
|
777
|
+
uri: `${API_BASE_URL}/operation/schedule`,
|
|
778
|
+
body: input,
|
|
779
|
+
apiKey
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
var getFullReceipt = async ({
|
|
783
|
+
opId,
|
|
784
|
+
chainId,
|
|
785
|
+
userOpHash,
|
|
786
|
+
apiKey
|
|
787
|
+
}) => {
|
|
788
|
+
const retries = 20;
|
|
789
|
+
let result = {
|
|
790
|
+
status: "pending"
|
|
791
|
+
};
|
|
792
|
+
for (let i = 0; i < retries; i++) {
|
|
793
|
+
try {
|
|
794
|
+
result = await sendGetRequest({
|
|
795
|
+
uri: `${API_BASE_URL}/operation/${opId}/chain/${chainId}/receipt?userOpHash=${userOpHash}`,
|
|
796
|
+
apiKey
|
|
797
|
+
});
|
|
798
|
+
if (result.status === "included") {
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
801
|
+
} catch (_err) {
|
|
802
|
+
}
|
|
803
|
+
await new Promise((resolve) => setTimeout(resolve, 2500));
|
|
804
|
+
}
|
|
805
|
+
if (!result.receipt) {
|
|
806
|
+
result.receipt = {
|
|
807
|
+
// TODO: this is obviously wrong but it was what we had before
|
|
808
|
+
txId: "Failed to find.",
|
|
809
|
+
gasUsed: "Failed to find.",
|
|
810
|
+
opFeeUSD: "Failed to find.",
|
|
811
|
+
opFee: "Failed to find.",
|
|
812
|
+
userOpHash: "Failed to find."
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
return {
|
|
816
|
+
...result.receipt
|
|
817
|
+
};
|
|
818
|
+
};
|
|
819
|
+
var getUserOpGasPrice = async ({
|
|
820
|
+
chainId,
|
|
821
|
+
apiKey
|
|
822
|
+
}) => {
|
|
823
|
+
return await sendGetRequest({
|
|
824
|
+
uri: `${API_BASE_URL}/operation/chain/${chainId}/gas-price`,
|
|
825
|
+
apiKey
|
|
826
|
+
});
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
// src/services/fw-operation/types.ts
|
|
830
|
+
var OperationStatus = /* @__PURE__ */ ((OperationStatus2) => {
|
|
831
|
+
OperationStatus2["ALL"] = "";
|
|
832
|
+
OperationStatus2["PENDING_APPROVED"] = "PENDING_APPROVED";
|
|
833
|
+
OperationStatus2["APPROVED"] = "APPROVED";
|
|
834
|
+
OperationStatus2["PENDING"] = "PENDING";
|
|
835
|
+
OperationStatus2["OP_SUCCEED"] = "OP_SUCCEED";
|
|
836
|
+
OperationStatus2["OP_REVERTED"] = "OP_REVERTED";
|
|
837
|
+
OperationStatus2["SCHEDULED"] = "SCHEDULED";
|
|
838
|
+
return OperationStatus2;
|
|
839
|
+
})(OperationStatus || {});
|
|
840
|
+
var AuthType = /* @__PURE__ */ ((AuthType2) => {
|
|
841
|
+
AuthType2[AuthType2["ECDSA"] = 0] = "ECDSA";
|
|
842
|
+
AuthType2[AuthType2["MULTI_SIG"] = 1] = "MULTI_SIG";
|
|
843
|
+
return AuthType2;
|
|
844
|
+
})(AuthType || {});
|
|
845
|
+
var OperationType = /* @__PURE__ */ ((OperationType2) => {
|
|
846
|
+
OperationType2["SINGLE_OPERATION"] = "SINGLE_OPERATION";
|
|
847
|
+
OperationType2["GROUP_OPERATION"] = "GROUP_OPERATION";
|
|
848
|
+
OperationType2["REJECTION"] = "REJECTION";
|
|
849
|
+
return OperationType2;
|
|
850
|
+
})(OperationType || {});
|
|
851
|
+
|
|
852
|
+
// src/services/fw-paymaster/endpoints.ts
|
|
853
|
+
async function addTransaction({
|
|
854
|
+
chainId,
|
|
855
|
+
timestamp,
|
|
856
|
+
txid,
|
|
857
|
+
transaction,
|
|
858
|
+
paymasterType,
|
|
859
|
+
sponsorAddress,
|
|
860
|
+
apiKey
|
|
861
|
+
}) {
|
|
862
|
+
try {
|
|
863
|
+
return await sendPostRequest({
|
|
864
|
+
uri: `${API_BASE_URL}/dashboard/paymasters/add-transaction`,
|
|
865
|
+
body: {
|
|
866
|
+
chain: chainId,
|
|
867
|
+
sponsorAddress,
|
|
868
|
+
type: paymasterType,
|
|
869
|
+
timestamp,
|
|
870
|
+
transaction,
|
|
871
|
+
txid
|
|
872
|
+
},
|
|
873
|
+
apiKey
|
|
874
|
+
});
|
|
875
|
+
} catch (_err) {
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/services/fw-paymaster/types.ts
|
|
880
|
+
var PaymasterType = /* @__PURE__ */ ((PaymasterType2) => {
|
|
881
|
+
PaymasterType2["BaseSponsor"] = "base";
|
|
882
|
+
PaymasterType2["GaslessSponsor"] = "gasless";
|
|
883
|
+
PaymasterType2["TokenSponsor"] = "token";
|
|
884
|
+
PaymasterType2["CheckoutSponsor"] = "checkout";
|
|
885
|
+
return PaymasterType2;
|
|
886
|
+
})(PaymasterType || {});
|
|
887
|
+
|
|
888
|
+
// src/services/fw-user/endpoints.ts
|
|
889
|
+
import { ResourceNotFoundError as ResourceNotFoundError4 } from "@funkit/utils";
|
|
890
|
+
import { InvalidParameterError as InvalidParameterError3 } from "viem";
|
|
891
|
+
async function createUser({
|
|
892
|
+
authId,
|
|
893
|
+
addr,
|
|
894
|
+
method,
|
|
895
|
+
userUniqueId,
|
|
896
|
+
apiKey
|
|
897
|
+
}) {
|
|
898
|
+
await sendPostRequest({
|
|
899
|
+
uri: `${API_BASE_URL}/user`,
|
|
900
|
+
body: {
|
|
901
|
+
authId,
|
|
902
|
+
addr,
|
|
903
|
+
method,
|
|
904
|
+
userUniqueId
|
|
905
|
+
},
|
|
906
|
+
apiKey
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
async function getUserUniqueId({
|
|
910
|
+
authId,
|
|
911
|
+
apiKey
|
|
912
|
+
}) {
|
|
913
|
+
try {
|
|
914
|
+
return (await sendGetRequest({
|
|
915
|
+
uri: `${API_BASE_URL}/user/auth/${authId}/unique-id`,
|
|
916
|
+
apiKey
|
|
917
|
+
})).userUniqueId;
|
|
918
|
+
} catch (err) {
|
|
919
|
+
if (err instanceof ResourceNotFoundError4) {
|
|
920
|
+
return "";
|
|
921
|
+
}
|
|
922
|
+
throw err;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
async function getUserWalletsByAddr({
|
|
926
|
+
addr,
|
|
927
|
+
apiKey,
|
|
928
|
+
chainId
|
|
929
|
+
}) {
|
|
930
|
+
const endpoint = chainId ? `${API_BASE_URL}/user/addr/${addr}/wallets?chainId=${chainId}` : `${API_BASE_URL}/user/addr/${addr}/wallets`;
|
|
931
|
+
return (await sendGetRequest({ uri: endpoint, apiKey })).wallets;
|
|
932
|
+
}
|
|
933
|
+
async function addUserToWallet({
|
|
934
|
+
authId,
|
|
935
|
+
chainId,
|
|
936
|
+
walletAddr,
|
|
937
|
+
userIds,
|
|
938
|
+
apiKey,
|
|
939
|
+
walletUniqueId
|
|
940
|
+
}) {
|
|
941
|
+
try {
|
|
942
|
+
await sendPostRequest({
|
|
943
|
+
uri: `${API_BASE_URL}/user/auth/${authId}/chain/${chainId}/wallet`,
|
|
944
|
+
body: { walletAddr, userIds, walletUniqueId },
|
|
945
|
+
apiKey
|
|
946
|
+
});
|
|
947
|
+
} catch (err) {
|
|
948
|
+
if (err instanceof InvalidParameterError3) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
async function getUserWalletIdentities({
|
|
954
|
+
authId,
|
|
955
|
+
chainId,
|
|
956
|
+
walletAddr,
|
|
957
|
+
apiKey
|
|
958
|
+
}) {
|
|
959
|
+
return (await sendGetRequest({
|
|
960
|
+
uri: `${API_BASE_URL}/user/auth/${authId}/chain/${chainId}/wallet/${walletAddr}/identities`,
|
|
961
|
+
apiKey
|
|
962
|
+
})).ids ?? [];
|
|
963
|
+
}
|
|
964
|
+
|
|
590
965
|
// src/services/mesh/endpoints.ts
|
|
591
966
|
async function meshGetCryptocurrencyHoldings({
|
|
592
967
|
authToken,
|
|
593
968
|
type,
|
|
594
969
|
apiKey
|
|
595
970
|
}) {
|
|
596
|
-
|
|
971
|
+
return sendPostRequest({
|
|
597
972
|
uri: `${API_BASE_URL}/mesh/holdings/get`,
|
|
598
973
|
body: { authToken, type },
|
|
599
974
|
apiKey
|
|
600
975
|
});
|
|
601
|
-
|
|
976
|
+
}
|
|
977
|
+
async function meshGetCryptocurrencyHoldingsProxy({
|
|
978
|
+
apiKey,
|
|
979
|
+
...props
|
|
980
|
+
}) {
|
|
981
|
+
return sendPostRequest({
|
|
982
|
+
uri: `${MESH_API_BASE_URL}/mesh/holdings/get`,
|
|
983
|
+
body: { ...props },
|
|
984
|
+
apiKey
|
|
985
|
+
});
|
|
602
986
|
}
|
|
603
987
|
async function meshGetTransferIntegrations({
|
|
604
988
|
apiKey
|
|
605
989
|
}) {
|
|
606
|
-
|
|
990
|
+
return sendGetRequest({
|
|
607
991
|
uri: `${API_BASE_URL}/mesh/transfers/managed/integrations`,
|
|
608
992
|
apiKey
|
|
609
993
|
});
|
|
610
|
-
return res;
|
|
611
994
|
}
|
|
612
995
|
async function meshGetLinkToken({
|
|
613
996
|
userId,
|
|
@@ -616,22 +999,17 @@ async function meshGetLinkToken({
|
|
|
616
999
|
transferOptions,
|
|
617
1000
|
apiKey
|
|
618
1001
|
}) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
if (transferOptions) {
|
|
627
|
-
body = { ...body, transferOptions };
|
|
628
|
-
}
|
|
629
|
-
const res = await sendPostRequest({
|
|
1002
|
+
const body = {
|
|
1003
|
+
userId,
|
|
1004
|
+
...integrationId && { integrationId },
|
|
1005
|
+
...restrictMultipleAccounts && { restrictMultipleAccounts },
|
|
1006
|
+
...transferOptions && { transferOptions }
|
|
1007
|
+
};
|
|
1008
|
+
return sendPostRequest({
|
|
630
1009
|
uri: `${API_BASE_URL}/mesh/linktoken`,
|
|
631
1010
|
body,
|
|
632
1011
|
apiKey
|
|
633
1012
|
});
|
|
634
|
-
return res;
|
|
635
1013
|
}
|
|
636
1014
|
async function meshPreviewTransfer({
|
|
637
1015
|
fromAuthToken,
|
|
@@ -646,38 +1024,36 @@ async function meshPreviewTransfer({
|
|
|
646
1024
|
fiatCurrency,
|
|
647
1025
|
apiKey
|
|
648
1026
|
}) {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
if (toAddress) {
|
|
663
|
-
body = { ...body, toAddress };
|
|
664
|
-
}
|
|
665
|
-
if (amount) {
|
|
666
|
-
body = { ...body, amount };
|
|
667
|
-
}
|
|
668
|
-
if (amountInFiat) {
|
|
669
|
-
body = { ...body, amountInFiat };
|
|
670
|
-
}
|
|
671
|
-
if (fiatCurrency) {
|
|
672
|
-
body = { ...body, fiatCurrency };
|
|
673
|
-
}
|
|
674
|
-
const res = await sendPostRequest({
|
|
1027
|
+
const body = {
|
|
1028
|
+
fromAuthToken,
|
|
1029
|
+
fromType,
|
|
1030
|
+
...toAuthToken && { toAuthToken },
|
|
1031
|
+
...toType && { toType },
|
|
1032
|
+
...networkId && { networkId },
|
|
1033
|
+
...symbol && { symbol },
|
|
1034
|
+
...toAddress && { toAddress },
|
|
1035
|
+
...amount && { amount },
|
|
1036
|
+
...amountInFiat && { amountInFiat },
|
|
1037
|
+
...fiatCurrency && { fiatCurrency }
|
|
1038
|
+
};
|
|
1039
|
+
return sendPostRequest({
|
|
675
1040
|
uri: `${API_BASE_URL}/mesh/transfers/managed/preview`,
|
|
676
1041
|
body,
|
|
677
1042
|
apiKey,
|
|
678
1043
|
retryOptions: { maxAttempts: 1 }
|
|
679
1044
|
});
|
|
680
|
-
|
|
1045
|
+
}
|
|
1046
|
+
async function meshPreviewTransferProxy({
|
|
1047
|
+
apiKey,
|
|
1048
|
+
...props
|
|
1049
|
+
}) {
|
|
1050
|
+
const body = { ...props };
|
|
1051
|
+
return sendPostRequest({
|
|
1052
|
+
uri: `${MESH_API_BASE_URL}/mesh/transfers/managed/preview`,
|
|
1053
|
+
body,
|
|
1054
|
+
apiKey,
|
|
1055
|
+
retryOptions: { maxAttempts: 1 }
|
|
1056
|
+
});
|
|
681
1057
|
}
|
|
682
1058
|
async function meshExecuteTransfer({
|
|
683
1059
|
fromAuthToken,
|
|
@@ -686,16 +1062,49 @@ async function meshExecuteTransfer({
|
|
|
686
1062
|
mfaCode,
|
|
687
1063
|
apiKey
|
|
688
1064
|
}) {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
1065
|
+
const body = {
|
|
1066
|
+
fromAuthToken,
|
|
1067
|
+
fromType,
|
|
1068
|
+
previewId,
|
|
1069
|
+
...mfaCode && { mfaCode }
|
|
1070
|
+
};
|
|
1071
|
+
return sendPostRequest({
|
|
694
1072
|
uri: `${API_BASE_URL}/mesh/transfers/managed/execute`,
|
|
695
1073
|
body,
|
|
696
1074
|
apiKey
|
|
697
1075
|
});
|
|
698
|
-
|
|
1076
|
+
}
|
|
1077
|
+
async function meshExecuteTransferProxy({
|
|
1078
|
+
apiKey,
|
|
1079
|
+
...props
|
|
1080
|
+
}) {
|
|
1081
|
+
const body = { ...props };
|
|
1082
|
+
return sendPostRequest({
|
|
1083
|
+
uri: `${MESH_API_BASE_URL}/mesh/transfers/managed/execute`,
|
|
1084
|
+
body,
|
|
1085
|
+
apiKey
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
async function saveTokensToMeshProxy({
|
|
1089
|
+
apiKey,
|
|
1090
|
+
...props
|
|
1091
|
+
}) {
|
|
1092
|
+
const body = { ...props };
|
|
1093
|
+
return sendPostRequest({
|
|
1094
|
+
uri: `${MESH_API_BASE_URL}/api/tokens`,
|
|
1095
|
+
body,
|
|
1096
|
+
apiKey
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
async function removeTokensFromMeshProxy({
|
|
1100
|
+
apiKey,
|
|
1101
|
+
...props
|
|
1102
|
+
}) {
|
|
1103
|
+
const body = { ...props };
|
|
1104
|
+
return await sendDeleteRequest({
|
|
1105
|
+
uri: `${MESH_API_BASE_URL}/api/tokens?deviceId=${body.deviceId}&brokerType=${body.brokerType}`,
|
|
1106
|
+
apiKey
|
|
1107
|
+
});
|
|
699
1108
|
}
|
|
700
1109
|
|
|
701
1110
|
// src/services/mesh/types.ts
|
|
@@ -761,12 +1170,11 @@ async function getMoonpayBuyQuoteForCreditCard({
|
|
|
761
1170
|
...extraFeePercentage == null ? {} : { extraFeePercentage: extraFeePercentage.toString() },
|
|
762
1171
|
...areFeesIncluded == null ? {} : { areFeesIncluded: areFeesIncluded.toString() }
|
|
763
1172
|
}).toString();
|
|
764
|
-
|
|
1173
|
+
return sendGetRequest({
|
|
765
1174
|
uri: `${API_BASE_URL}/on-ramp/moonpay-buy-quote?${params}`,
|
|
766
1175
|
apiKey,
|
|
767
1176
|
retryOptions: { maxAttempts: 1 }
|
|
768
1177
|
});
|
|
769
|
-
return res;
|
|
770
1178
|
}
|
|
771
1179
|
|
|
772
1180
|
// src/services/stripe/endpoints.ts
|
|
@@ -861,48 +1269,86 @@ async function sendSupportMessage({
|
|
|
861
1269
|
}
|
|
862
1270
|
export {
|
|
863
1271
|
API_BASE_URL,
|
|
1272
|
+
AuthType,
|
|
864
1273
|
CheckoutState,
|
|
865
1274
|
DEFAULT_RETRY_OPTIONS,
|
|
1275
|
+
DEGEN_API_KEY,
|
|
1276
|
+
DEV_API_KEY,
|
|
1277
|
+
DYDX_API_KEY,
|
|
866
1278
|
FUN_FAUCET_URL,
|
|
1279
|
+
MESH_API_BASE_URL,
|
|
867
1280
|
MeshExecuteTransferMfaType,
|
|
868
1281
|
MeshExecuteTransferStatus,
|
|
1282
|
+
OperationStatus,
|
|
1283
|
+
OperationType,
|
|
1284
|
+
POLYMARKET_API_KEY,
|
|
1285
|
+
PaymasterType,
|
|
1286
|
+
addTransaction,
|
|
1287
|
+
addUserToWallet,
|
|
1288
|
+
checkWalletAccessInitialization,
|
|
1289
|
+
createOp,
|
|
869
1290
|
createStripeBuySession,
|
|
1291
|
+
createUser,
|
|
870
1292
|
deactivateCheckout,
|
|
1293
|
+
deleteOp,
|
|
871
1294
|
errorAbortHandler,
|
|
1295
|
+
estimateOp,
|
|
1296
|
+
executeOp,
|
|
872
1297
|
generateRandomCheckoutSalt,
|
|
873
1298
|
getAllWalletNFTs,
|
|
874
1299
|
getAllWalletNFTsByChainId,
|
|
875
1300
|
getAllWalletTokens,
|
|
876
1301
|
getAllWalletTokensByChainId,
|
|
877
1302
|
getAllowedAssets,
|
|
1303
|
+
getAssetErc20ByChainAndSymbol,
|
|
878
1304
|
getAssetFromFaucet,
|
|
879
1305
|
getAssetPriceInfo,
|
|
1306
|
+
getChainFromId,
|
|
1307
|
+
getChainFromName,
|
|
880
1308
|
getCheckoutByDepositAddress,
|
|
881
1309
|
getCheckoutQuote,
|
|
882
1310
|
getCheckoutsByFunWalletAddress,
|
|
883
1311
|
getCheckoutsByRecipientAddress,
|
|
884
1312
|
getCheckoutsByUserId,
|
|
1313
|
+
getFullReceipt,
|
|
1314
|
+
getGroups,
|
|
885
1315
|
getMoonpayBuyQuoteForCreditCard,
|
|
886
1316
|
getMoonpayUrlSignature,
|
|
1317
|
+
getNftAddress,
|
|
1318
|
+
getNftName,
|
|
1319
|
+
getOps,
|
|
1320
|
+
getOpsOfWallet,
|
|
887
1321
|
getPaymasterDataForCheckoutSponsoredTransfer,
|
|
888
1322
|
getRiskAssessmentForAddress,
|
|
889
1323
|
getStripeBuyQuote,
|
|
890
1324
|
getStripeBuySession,
|
|
1325
|
+
getUserOpGasPrice,
|
|
1326
|
+
getUserUniqueId,
|
|
1327
|
+
getUserWalletIdentities,
|
|
1328
|
+
getUserWalletsByAddr,
|
|
891
1329
|
getWalletLidoWithdrawalsByChainId,
|
|
892
1330
|
initializeCheckout,
|
|
893
1331
|
initializeCheckoutTokenTransferAddress,
|
|
1332
|
+
initializeWalletAccess,
|
|
894
1333
|
meshExecuteTransfer,
|
|
1334
|
+
meshExecuteTransferProxy,
|
|
895
1335
|
meshGetCryptocurrencyHoldings,
|
|
1336
|
+
meshGetCryptocurrencyHoldingsProxy,
|
|
896
1337
|
meshGetLinkToken,
|
|
897
1338
|
meshGetTransferIntegrations,
|
|
898
1339
|
meshPreviewTransfer,
|
|
1340
|
+
meshPreviewTransferProxy,
|
|
899
1341
|
randomBytes,
|
|
1342
|
+
removeTokensFromMeshProxy,
|
|
900
1343
|
roundToNearestBottomTenth,
|
|
1344
|
+
saveTokensToMeshProxy,
|
|
1345
|
+
scheduleOp,
|
|
901
1346
|
sendDeleteRequest,
|
|
902
1347
|
sendGetRequest,
|
|
903
1348
|
sendPostRequest,
|
|
904
1349
|
sendPutRequest,
|
|
905
1350
|
sendRequest,
|
|
906
|
-
sendSupportMessage
|
|
1351
|
+
sendSupportMessage,
|
|
1352
|
+
signOp
|
|
907
1353
|
};
|
|
908
1354
|
//# sourceMappingURL=index.js.map
|