@funkit/core 2.0.1 → 2.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/dist/index.js +11 -27
- package/dist/index.js.map +1 -1
- package/dist/src/abis/ApproveAndExec.json +45 -9
- package/dist/src/abis/ApproveAndSwap.json +141 -1
- package/dist/src/abis/CheckoutPaymaster.json +3358 -1
- package/dist/src/abis/EntryPoint.json +590 -113
- package/dist/src/abis/EstimationPaymaster.json +134 -24
- package/dist/src/abis/FeePercentOracle.json +94 -18
- package/dist/src/abis/FunWallet.json +280 -56
- package/dist/src/abis/FunWalletFactory.json +112 -21
- package/dist/src/abis/GaslessPaymaster.json +279 -50
- package/dist/src/abis/RoleBasedAccessControl.json +2 -1
- package/dist/src/abis/TestNFT.json +71 -15
- package/dist/src/abis/TokenPriceOracle.json +17 -4
- package/dist/src/abis/UserAuthentication.json +147 -32
- package/dist/src/actions/AccessControl.js +39 -48
- package/dist/src/actions/AccessControl.js.map +1 -1
- package/dist/src/actions/BatchActions.js +3 -7
- package/dist/src/actions/BatchActions.js.map +1 -1
- package/dist/src/actions/Bridge.js +16 -20
- package/dist/src/actions/Bridge.js.map +1 -1
- package/dist/src/actions/FirstClassActions.js +74 -77
- package/dist/src/actions/FirstClassActions.js.map +1 -1
- package/dist/src/actions/Group.js +14 -20
- package/dist/src/actions/Group.js.map +1 -1
- package/dist/src/actions/LimitOrder.js +18 -22
- package/dist/src/actions/LimitOrder.js.map +1 -1
- package/dist/src/actions/Stake.js +40 -43
- package/dist/src/actions/Stake.js.map +1 -1
- package/dist/src/actions/Swap.js +40 -46
- package/dist/src/actions/Swap.js.map +1 -1
- package/dist/src/actions/Token.js +41 -53
- package/dist/src/actions/Token.js.map +1 -1
- package/dist/src/actions/index.js +7 -23
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/actions/types.js +4 -7
- package/dist/src/actions/types.js.map +1 -1
- package/dist/src/apis/AccessControlApis.js +10 -16
- package/dist/src/apis/AccessControlApis.js.map +1 -1
- package/dist/src/apis/BridgeApis.js +14 -20
- package/dist/src/apis/BridgeApis.js.map +1 -1
- package/dist/src/apis/ContractApis.js +4 -7
- package/dist/src/apis/ContractApis.js.map +1 -1
- package/dist/src/apis/GroupApis.js +6 -10
- package/dist/src/apis/GroupApis.js.map +1 -1
- package/dist/src/apis/InfoApis.js +16 -23
- package/dist/src/apis/InfoApis.js.map +1 -1
- package/dist/src/apis/ListenerApis.js +9 -13
- package/dist/src/apis/ListenerApis.js.map +1 -1
- package/dist/src/apis/NFTApis.js +6 -10
- package/dist/src/apis/NFTApis.js.map +1 -1
- package/dist/src/apis/OperationApis.js +26 -40
- package/dist/src/apis/OperationApis.js.map +1 -1
- package/dist/src/apis/PaymasterApis.js +4 -7
- package/dist/src/apis/PaymasterApis.js.map +1 -1
- package/dist/src/apis/SwapApis.js +8 -13
- package/dist/src/apis/SwapApis.js.map +1 -1
- package/dist/src/apis/UserApis.js +20 -29
- package/dist/src/apis/UserApis.js.map +1 -1
- package/dist/src/apis/index.js +8 -24
- package/dist/src/apis/index.js.map +1 -1
- package/dist/src/apis/types.js +1 -2
- package/dist/src/auth/Auth.js +60 -76
- package/dist/src/auth/Auth.js.map +1 -1
- package/dist/src/auth/SessionKeyAuth.js +30 -33
- package/dist/src/auth/SessionKeyAuth.js.map +1 -1
- package/dist/src/auth/index.js +2 -18
- package/dist/src/auth/index.js.map +1 -1
- package/dist/src/auth/types.js +1 -2
- package/dist/src/common/constants.d.ts +141 -3
- package/dist/src/common/constants.js +211 -191
- package/dist/src/common/constants.js.map +1 -1
- package/dist/src/common/index.js +2 -18
- package/dist/src/common/index.js.map +1 -1
- package/dist/src/common/types.js +1 -2
- package/dist/src/config/Config.js +8 -13
- package/dist/src/config/Config.js.map +1 -1
- package/dist/src/config/index.js +2 -18
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/config/types.js +1 -2
- package/dist/src/data/Chain.js +35 -33
- package/dist/src/data/Chain.js.map +1 -1
- package/dist/src/data/NFT.js +28 -31
- package/dist/src/data/NFT.js.map +1 -1
- package/dist/src/data/Operation.js +28 -11
- package/dist/src/data/Operation.js.map +1 -1
- package/dist/src/data/SolidityData.js +23 -30
- package/dist/src/data/SolidityData.js.map +1 -1
- package/dist/src/data/Token.js +21 -23
- package/dist/src/data/Token.js.map +1 -1
- package/dist/src/data/index.js +6 -22
- package/dist/src/data/index.js.map +1 -1
- package/dist/src/data/types.js +6 -9
- package/dist/src/data/types.js.map +1 -1
- package/dist/src/errors/BaseError.js +6 -5
- package/dist/src/errors/BaseError.js.map +1 -1
- package/dist/src/errors/ClientError.js +21 -34
- package/dist/src/errors/ClientError.js.map +1 -1
- package/dist/src/errors/ServerError.js +6 -11
- package/dist/src/errors/ServerError.js.map +1 -1
- package/dist/src/errors/index.js +4 -20
- package/dist/src/errors/index.js.map +1 -1
- package/dist/src/errors/types.js +6 -9
- package/dist/src/errors/types.js.map +1 -1
- package/dist/src/sponsors/CheckoutSponsor.js +10 -14
- package/dist/src/sponsors/CheckoutSponsor.js.map +1 -1
- package/dist/src/sponsors/GaslessSponsor.js +23 -27
- package/dist/src/sponsors/GaslessSponsor.js.map +1 -1
- package/dist/src/sponsors/Sponsor.js +10 -8
- package/dist/src/sponsors/Sponsor.js.map +1 -1
- package/dist/src/sponsors/TokenSponsor.js +79 -82
- package/dist/src/sponsors/TokenSponsor.js.map +1 -1
- package/dist/src/sponsors/index.js +4 -20
- package/dist/src/sponsors/index.js.map +1 -1
- package/dist/src/sponsors/types.js +2 -5
- package/dist/src/sponsors/types.js.map +1 -1
- package/dist/src/utils/ApiUtils.js +30 -38
- package/dist/src/utils/ApiUtils.js.map +1 -1
- package/dist/src/utils/AuthUtils.js +9 -14
- package/dist/src/utils/AuthUtils.js.map +1 -1
- package/dist/src/utils/ChainUtils.js +38 -49
- package/dist/src/utils/ChainUtils.js.map +1 -1
- package/dist/src/utils/CheckoutUtils.js +13 -18
- package/dist/src/utils/CheckoutUtils.js.map +1 -1
- package/dist/src/utils/GroupUtils.js +6 -9
- package/dist/src/utils/GroupUtils.js.map +1 -1
- package/dist/src/utils/MerkleUtils.js +34 -47
- package/dist/src/utils/MerkleUtils.js.map +1 -1
- package/dist/src/utils/PaymasterUtils.js +5 -9
- package/dist/src/utils/PaymasterUtils.js.map +1 -1
- package/dist/src/utils/SwapUtils.js +44 -43
- package/dist/src/utils/SwapUtils.js.map +1 -1
- package/dist/src/utils/TypeUtils.js +5 -9
- package/dist/src/utils/TypeUtils.js.map +1 -1
- package/dist/src/utils/UserOpUtils.js +20 -29
- package/dist/src/utils/UserOpUtils.js.map +1 -1
- package/dist/src/utils/ViemUtils.js +6 -12
- package/dist/src/utils/ViemUtils.js.map +1 -1
- package/dist/src/utils/WalletUtils.js +28 -42
- package/dist/src/utils/WalletUtils.js.map +1 -1
- package/dist/src/utils/index.js +8 -24
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/viem/ContractInterface.js +14 -18
- package/dist/src/viem/ContractInterface.js.map +1 -1
- package/dist/src/viem/Converter.js +15 -20
- package/dist/src/viem/Converter.js.map +1 -1
- package/dist/src/viem/index.js +2 -18
- package/dist/src/viem/index.js.map +1 -1
- package/dist/src/wallet/FunWallet.js +141 -142
- package/dist/src/wallet/FunWallet.js.map +1 -1
- package/dist/src/wallet/index.js +2 -18
- package/dist/src/wallet/index.js.map +1 -1
- package/dist/src/wallet/types.js +1 -2
- package/package.json +4 -2
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SocketSort = exports.UniswapPoolFeeOptions = void 0;
|
|
4
|
-
var UniswapPoolFeeOptions;
|
|
1
|
+
export var UniswapPoolFeeOptions;
|
|
5
2
|
(function (UniswapPoolFeeOptions) {
|
|
6
3
|
UniswapPoolFeeOptions["lowest"] = "lowest";
|
|
7
4
|
UniswapPoolFeeOptions["low"] = "low";
|
|
8
5
|
UniswapPoolFeeOptions["medium"] = "medium";
|
|
9
6
|
UniswapPoolFeeOptions["high"] = "high";
|
|
10
|
-
})(UniswapPoolFeeOptions || (
|
|
11
|
-
var SocketSort;
|
|
7
|
+
})(UniswapPoolFeeOptions || (UniswapPoolFeeOptions = {}));
|
|
8
|
+
export var SocketSort;
|
|
12
9
|
(function (SocketSort) {
|
|
13
10
|
SocketSort["output"] = "output";
|
|
14
11
|
SocketSort["gas"] = "gas";
|
|
15
12
|
SocketSort["time"] = "time";
|
|
16
|
-
})(SocketSort || (
|
|
13
|
+
})(SocketSort || (SocketSort = {}));
|
|
17
14
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"AAuDA,MAAM,CAAN,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC/B,0CAAiB,CAAA;IACjB,oCAAW,CAAA;IACX,0CAAiB,CAAA;IACjB,sCAAa,CAAA;AACf,CAAC,EALW,qBAAqB,KAArB,qBAAqB,QAKhC;AA2GD,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,yBAAW,CAAA;IACX,2BAAa,CAAA;AACf,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB"}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.addAccessToWallet = addAccessToWallet;
|
|
6
|
-
exports.addAccessToUser = addAccessToUser;
|
|
7
|
-
const constants_1 = require("../common/constants");
|
|
8
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
9
|
-
async function initializeWalletAccess(walletAddr, creatorAddr) {
|
|
10
|
-
await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'access/wallet', { walletAddr, creatorAddr });
|
|
1
|
+
import { API_URL } from '../common/constants';
|
|
2
|
+
import { sendGetRequest, sendPostRequest } from '../utils/ApiUtils';
|
|
3
|
+
export async function initializeWalletAccess(walletAddr, creatorAddr) {
|
|
4
|
+
await sendPostRequest(API_URL, 'access/wallet', { walletAddr, creatorAddr });
|
|
11
5
|
}
|
|
12
|
-
async function checkWalletAccessInitialization(walletAddr) {
|
|
13
|
-
return (await
|
|
6
|
+
export async function checkWalletAccessInitialization(walletAddr) {
|
|
7
|
+
return (await sendGetRequest(API_URL, `access/wallet/${walletAddr}`))
|
|
14
8
|
.initialized;
|
|
15
9
|
}
|
|
16
|
-
async function addAccessToWallet(walletAddr, nonce, signature) {
|
|
17
|
-
await
|
|
10
|
+
export async function addAccessToWallet(walletAddr, nonce, signature) {
|
|
11
|
+
await sendPostRequest(API_URL, `access/wallet/${walletAddr}`, {
|
|
18
12
|
nonce,
|
|
19
13
|
signature,
|
|
20
14
|
});
|
|
21
15
|
}
|
|
22
|
-
async function addAccessToUser(authId, nonce, signature) {
|
|
23
|
-
await
|
|
16
|
+
export async function addAccessToUser(authId, nonce, signature) {
|
|
17
|
+
await sendPostRequest(API_URL, `access/user/${authId}`, { nonce, signature });
|
|
24
18
|
}
|
|
25
19
|
//# sourceMappingURL=AccessControlApis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessControlApis.js","sourceRoot":"","sources":["../../../src/apis/AccessControlApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AccessControlApis.js","sourceRoot":"","sources":["../../../src/apis/AccessControlApis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,UAAmB,EACnB,WAAoB;IAEpB,MAAM,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAA;AAC9E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,UAAmB;IAEnB,OAAO,CAAC,MAAM,cAAc,CAAC,OAAO,EAAE,iBAAiB,UAAU,EAAE,CAAC,CAAC;SAClE,WAAW,CAAA;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAmB,EACnB,KAAa,EACb,SAAc;IAEd,MAAM,eAAe,CAAC,OAAO,EAAE,iBAAiB,UAAU,EAAE,EAAE;QAC5D,KAAK;QACL,SAAS;KACV,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,KAAa,EACb,SAAc;IAEd,MAAM,eAAe,CAAC,OAAO,EAAE,eAAe,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;AAC/E,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.getSocketBridgeAllowance = getSocketBridgeAllowance;
|
|
6
|
-
exports.getSocketBridgeApproveTransaction = getSocketBridgeApproveTransaction;
|
|
7
|
-
const constants_1 = require("../common/constants");
|
|
8
|
-
const errors_1 = require("../errors");
|
|
9
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
10
|
-
async function getSocketBridgeQuote(recipient, walletAddress, fromChain, toChain, fromToken, toToken, amount, sort) {
|
|
1
|
+
import { API_URL } from '../common/constants';
|
|
2
|
+
import { ErrorCode, ResourceNotFoundError } from '../errors';
|
|
3
|
+
import { sendGetRequest, sendPostRequest } from '../utils/ApiUtils';
|
|
4
|
+
export async function getSocketBridgeQuote(recipient, walletAddress, fromChain, toChain, fromToken, toToken, amount, sort) {
|
|
11
5
|
const params = new URLSearchParams({
|
|
12
6
|
recipient,
|
|
13
7
|
fromChainId: fromChain,
|
|
@@ -20,30 +14,30 @@ async function getSocketBridgeQuote(recipient, walletAddress, fromChain, toChain
|
|
|
20
14
|
sort,
|
|
21
15
|
singleTxOnly: 'true',
|
|
22
16
|
}).toString();
|
|
23
|
-
const quote = await
|
|
17
|
+
const quote = await sendGetRequest(API_URL, `bridge/quote/?${params}`);
|
|
24
18
|
if (!quote.success || quote.result.routes.length === 0) {
|
|
25
|
-
throw new
|
|
19
|
+
throw new ResourceNotFoundError(ErrorCode.BridgeRouteNotFound, 'Unable to find a route for these assets between these chains', { walletAddress, fromChain, toChain, fromToken, toToken, amount, sort }, 'Try another route with a different asset pair', 'https://docs.fun.xyz');
|
|
26
20
|
}
|
|
27
21
|
const route = quote.result.routes[0];
|
|
28
22
|
return route;
|
|
29
23
|
}
|
|
30
|
-
async function getSocketBridgeTransaction(route) {
|
|
31
|
-
return await
|
|
24
|
+
export async function getSocketBridgeTransaction(route) {
|
|
25
|
+
return await sendPostRequest(API_URL, 'bridge/build-tx/', { route });
|
|
32
26
|
}
|
|
33
|
-
async function getSocketBridgeAllowance(chainId, sender, allowanceTarget, token) {
|
|
27
|
+
export async function getSocketBridgeAllowance(chainId, sender, allowanceTarget, token) {
|
|
34
28
|
const params = new URLSearchParams({
|
|
35
29
|
chainId,
|
|
36
30
|
owner: sender,
|
|
37
31
|
allowanceTarget,
|
|
38
32
|
tokenAddress: token,
|
|
39
33
|
}).toString();
|
|
40
|
-
const json = await
|
|
34
|
+
const json = await sendGetRequest(API_URL, `bridge/approval/check-allowance/?${params}`);
|
|
41
35
|
if (!json.result.value) {
|
|
42
|
-
throw new
|
|
36
|
+
throw new ResourceNotFoundError(ErrorCode.BridgeAllowanceDataNotFound, 'Unable to get allowance data', { chainId, sender, allowanceTarget, token }, 'Make sure the chainId, sender, allowanceTarget, and token are correct', 'https://docs.fun.xyz');
|
|
43
37
|
}
|
|
44
38
|
return json;
|
|
45
39
|
}
|
|
46
|
-
async function getSocketBridgeApproveTransaction(chainId, sender, allowanceTarget, token, amount) {
|
|
40
|
+
export async function getSocketBridgeApproveTransaction(chainId, sender, allowanceTarget, token, amount) {
|
|
47
41
|
const params = new URLSearchParams({
|
|
48
42
|
chainId,
|
|
49
43
|
owner: sender,
|
|
@@ -51,9 +45,9 @@ async function getSocketBridgeApproveTransaction(chainId, sender, allowanceTarge
|
|
|
51
45
|
tokenAddress: token,
|
|
52
46
|
amount: amount.toString(),
|
|
53
47
|
}).toString();
|
|
54
|
-
const json = await
|
|
48
|
+
const json = await sendGetRequest(API_URL, `bridge/approval/build-tx/?${params}`);
|
|
55
49
|
if (!json.result) {
|
|
56
|
-
throw new
|
|
50
|
+
throw new ResourceNotFoundError(ErrorCode.BridgeApproveTxDataNotFound, 'Unable to build the approve transaction data', { chainId, sender, allowanceTarget, token, amount }, 'Make sure the token and allowance are valid values', 'https://docs.fun.xyz');
|
|
57
51
|
}
|
|
58
52
|
return json;
|
|
59
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BridgeApis.js","sourceRoot":"","sources":["../../../src/apis/BridgeApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BridgeApis.js","sourceRoot":"","sources":["../../../src/apis/BridgeApis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,SAAiB,EACjB,aAAqB,EACrB,SAAiB,EACjB,OAAe,EACf,SAAiB,EACjB,OAAe,EACf,MAAc,EACd,IAAY;IAEZ,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,SAAS;QACT,WAAW,EAAE,SAAS;QACtB,gBAAgB,EAAE,SAAS;QAC3B,SAAS,EAAE,OAAO;QAClB,cAAc,EAAE,OAAO;QACvB,UAAU,EAAE,MAAM,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,SAAS,CAAC,2BAA2B,EACrC,8BAA8B,EAC9B,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,EAC3C,uEAAuE,EACvE,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,OAAe,EACf,MAAe,EACf,eAAuB,EACvB,KAAa,EACb,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,OAAO;QACP,KAAK,EAAE,MAAM;QACb,eAAe;QACf,YAAY,EAAE,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;KAC1B,CAAC,CAAC,QAAQ,EAAE,CAAA;IACb,MAAM,IAAI,GAAG,MAAM,cAAc,CAC/B,OAAO,EACP,6BAA6B,MAAM,EAAE,CACtC,CAAA;IACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,IAAI,qBAAqB,CAC7B,SAAS,CAAC,2BAA2B,EACrC,8CAA8C,EAC9C,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,EACnD,oDAAoD,EACpD,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
6
|
-
async function getContractAbi(contractName, mode = 'abi') {
|
|
7
|
-
const { name, abi, addresses } = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `contract/${contractName}?mode=${mode}`);
|
|
1
|
+
import { API_URL } from '../common/constants';
|
|
2
|
+
import { sendGetRequest } from '../utils/ApiUtils';
|
|
3
|
+
export async function getContractAbi(contractName, mode = 'abi') {
|
|
4
|
+
const { name, abi, addresses } = await sendGetRequest(API_URL, `contract/${contractName}?mode=${mode}`);
|
|
8
5
|
return { name, abi, addresses };
|
|
9
6
|
}
|
|
10
7
|
//# sourceMappingURL=ContractApis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractApis.js","sourceRoot":"","sources":["../../../src/apis/ContractApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractApis.js","sourceRoot":"","sources":["../../../src/apis/ContractApis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,YAAoB,EACpB,IAAI,GAAG,KAAK;IAEZ,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,MAAM,cAAc,CACnD,OAAO,EACP,YAAY,YAAY,SAAS,IAAI,EAAE,CACxC,CAAA;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,CAAA;AACjC,CAAC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const constants_1 = require("../common/constants");
|
|
6
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
7
|
-
async function getGroups(groupIds, chainId) {
|
|
8
|
-
return (await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'group/get-groups', {
|
|
1
|
+
import { API_URL } from '../common/constants';
|
|
2
|
+
import { sendPostRequest } from '../utils/ApiUtils';
|
|
3
|
+
export async function getGroups(groupIds, chainId) {
|
|
4
|
+
return (await sendPostRequest(API_URL, 'group/get-groups', {
|
|
9
5
|
groupIds,
|
|
10
6
|
chainId,
|
|
11
7
|
})).groups;
|
|
12
8
|
}
|
|
13
|
-
async function getGroupsByWallet(walletAddr, chainId) {
|
|
14
|
-
return (await
|
|
9
|
+
export async function getGroupsByWallet(walletAddr, chainId) {
|
|
10
|
+
return (await sendPostRequest(API_URL, `group/wallet/${walletAddr}/chain/${chainId}`, {
|
|
15
11
|
walletAddr,
|
|
16
12
|
chainId,
|
|
17
13
|
})).groups;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupApis.js","sourceRoot":"","sources":["../../../src/apis/GroupApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GroupApis.js","sourceRoot":"","sources":["../../../src/apis/GroupApis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAGnD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,QAAe,EACf,OAAe;IAEf,OAAO,CACL,MAAM,eAAe,CAAC,OAAO,EAAE,kBAAkB,EAAE;QACjD,QAAQ;QACR,OAAO;KACR,CAAC,CACH,CAAC,MAAM,CAAA;AACV,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAmB,EACnB,OAAe;IAEf,OAAO,CACL,MAAM,eAAe,CACnB,OAAO,EACP,gBAAgB,UAAU,UAAU,OAAO,EAAE,EAC7C;QACE,UAAU;QACV,OAAO;KACR,CACF,CACF,CAAC,MAAM,CAAA;AACV,CAAC"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.getChainFromName = getChainFromName;
|
|
6
|
-
exports.getModuleInfo = getModuleInfo;
|
|
7
|
-
exports.getPaymasterAddress = getPaymasterAddress;
|
|
8
|
-
const constants_1 = require("../common/constants");
|
|
9
|
-
const errors_1 = require("../errors");
|
|
10
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
11
|
-
async function getTokenInfo(symbol, chainId) {
|
|
1
|
+
import { API_URL, BASE_WRAP_TOKEN_ADDR } from '../common/constants';
|
|
2
|
+
import { ErrorCode, ResourceNotFoundError } from '../errors';
|
|
3
|
+
import { sendGetRequest, sendPostRequest } from '../utils/ApiUtils';
|
|
4
|
+
export async function getTokenInfo(symbol, chainId) {
|
|
12
5
|
symbol = symbol.toLowerCase();
|
|
13
6
|
const body = {
|
|
14
7
|
symbol,
|
|
@@ -16,44 +9,44 @@ async function getTokenInfo(symbol, chainId) {
|
|
|
16
9
|
};
|
|
17
10
|
if (symbol === 'weth' &&
|
|
18
11
|
chainId !== '137' &&
|
|
19
|
-
Object.keys(
|
|
20
|
-
return
|
|
12
|
+
Object.keys(BASE_WRAP_TOKEN_ADDR).includes(chainId)) {
|
|
13
|
+
return BASE_WRAP_TOKEN_ADDR[chainId][symbol];
|
|
21
14
|
}
|
|
22
15
|
else if (symbol === 'wmatic' && chainId === '137') {
|
|
23
|
-
return
|
|
16
|
+
return BASE_WRAP_TOKEN_ADDR[chainId][symbol];
|
|
24
17
|
}
|
|
25
|
-
const tokenInfo = await
|
|
18
|
+
const tokenInfo = await sendGetRequest(API_URL, `asset/erc20/${body.chain}/${body.symbol}`);
|
|
26
19
|
if (tokenInfo.address) {
|
|
27
20
|
return tokenInfo.address;
|
|
28
21
|
}
|
|
29
|
-
throw new
|
|
22
|
+
throw new ResourceNotFoundError(ErrorCode.TokenNotFound, 'token symbol does not exist on provided chain', { symbol, chainId }, 'Provide correct symbol and chainId.', 'https://docs.fun.xyz');
|
|
30
23
|
}
|
|
31
|
-
async function getChainFromId(chainId) {
|
|
32
|
-
return await
|
|
24
|
+
export async function getChainFromId(chainId) {
|
|
25
|
+
return await sendGetRequest(API_URL, `chain-info/${chainId}`).then((r) => {
|
|
33
26
|
if (!r) {
|
|
34
27
|
throw new Error(JSON.stringify(r));
|
|
35
28
|
}
|
|
36
29
|
return r;
|
|
37
30
|
});
|
|
38
31
|
}
|
|
39
|
-
async function getChainFromName(name) {
|
|
40
|
-
return await
|
|
32
|
+
export async function getChainFromName(name) {
|
|
33
|
+
return await sendGetRequest(API_URL, `chain-info?name=${name}`).then((r) => {
|
|
41
34
|
if (!r) {
|
|
42
35
|
throw new Error(JSON.stringify(r));
|
|
43
36
|
}
|
|
44
37
|
return r;
|
|
45
38
|
});
|
|
46
39
|
}
|
|
47
|
-
async function getModuleInfo(moduleName, chainId) {
|
|
40
|
+
export async function getModuleInfo(moduleName, chainId) {
|
|
48
41
|
const body = {
|
|
49
42
|
module: moduleName,
|
|
50
43
|
chain: chainId,
|
|
51
44
|
};
|
|
52
|
-
return await
|
|
45
|
+
return await sendPostRequest(API_URL, 'get-module-info', body).then((r) => {
|
|
53
46
|
return r.data;
|
|
54
47
|
});
|
|
55
48
|
}
|
|
56
|
-
async function getPaymasterAddress(chainId) {
|
|
49
|
+
export async function getPaymasterAddress(chainId) {
|
|
57
50
|
const { moduleAddresses: { paymaster: { paymasterAddress }, }, } = await getChainFromId(chainId);
|
|
58
51
|
return paymasterAddress;
|
|
59
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoApis.js","sourceRoot":"","sources":["../../../src/apis/InfoApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InfoApis.js","sourceRoot":"","sources":["../../../src/apis/InfoApis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,OAAe;IAEf,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IAC7B,MAAM,IAAI,GAAG;QACX,MAAM;QACN,KAAK,EAAE,OAAO;KACf,CAAA;IACD,IACE,MAAM,KAAK,MAAM;QACjB,OAAO,KAAK,KAAK;QACjB,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CA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;QACpC,CAAC;QACD,OAAO,CAAC,CAAA;IACV,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAkB,EAClB,OAAe;IAEf,MAAM,IAAI,GAAG;QACX,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,OAAO;KACf,CAAA;IAED,OAAO,MAAM,eAAe,CAAC,OAAO,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QACxE,OAAO,CAAC,CAAC,IAAI,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAe;IACvD,MAAM,EACJ,eAAe,EAAE,EACf,SAAS,EAAE,EAAE,gBAAgB,EAAE,GAChC,GACF,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAA;IAEjC,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const constants_1 = require("../common/constants");
|
|
6
|
-
const errors_1 = require("../errors");
|
|
7
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
8
|
-
async function createListener(walletAddresses, chains, webhookUrl) {
|
|
1
|
+
import { API_URL } from '../common/constants';
|
|
2
|
+
import { ErrorCode, InternalFailureError } from '../errors';
|
|
3
|
+
import { sendPostRequest } from '../utils/ApiUtils';
|
|
4
|
+
export async function createListener(walletAddresses, chains, webhookUrl) {
|
|
9
5
|
const body = {
|
|
10
6
|
walletAddresses,
|
|
11
7
|
chains,
|
|
12
8
|
webhookUrl,
|
|
13
9
|
};
|
|
14
|
-
const result = await
|
|
10
|
+
const result = await sendPostRequest(API_URL, 'listeners/', body).then((r) => {
|
|
15
11
|
return r;
|
|
16
12
|
});
|
|
17
13
|
if (!result) {
|
|
18
|
-
throw new
|
|
14
|
+
throw new InternalFailureError(ErrorCode.UnknownServerError, 'Listener call failed.', { walletAddresses, chains, webhookUrl }, 'This is an internal error, please contact support.', 'https://docs.fun.xyz');
|
|
19
15
|
}
|
|
20
16
|
return result;
|
|
21
17
|
}
|
|
22
|
-
async function deleteListener(walletAddress, chain) {
|
|
18
|
+
export async function deleteListener(walletAddress, chain) {
|
|
23
19
|
const body = {
|
|
24
20
|
walletAddress,
|
|
25
21
|
chain,
|
|
26
22
|
};
|
|
27
|
-
const result = await
|
|
23
|
+
const result = await sendPostRequest(API_URL, 'listeners/delete', body).then((r) => {
|
|
28
24
|
return r;
|
|
29
25
|
});
|
|
30
26
|
if (!result) {
|
|
31
|
-
throw new
|
|
27
|
+
throw new InternalFailureError(ErrorCode.UnknownServerError, 'Listener call failed.', { walletAddress, chain }, 'This is an internal error, please contact support.', 'https://docs.fun.xyz');
|
|
32
28
|
}
|
|
33
29
|
return result;
|
|
34
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListenerApis.js","sourceRoot":"","sources":["../../../src/apis/ListenerApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ListenerApis.js","sourceRoot":"","sources":["../../../src/apis/ListenerApis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,eAA0B,EAC1B,MAAgB,EAChB,UAAkB;IAElB,MAAM,IAAI,GAAG;QACX,eAAe;QACf,MAAM;QACN,UAAU;KACX,CAAA;IACD,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,CACpE,CAAC,CAAC,EAAE,EAAE;QACJ,OAAO,CAAC,CAAA;IACV,CAAC,CACF,CAAA;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,oBAAoB,CAC5B,SAAS,CAAC,kBAAkB,EAC5B,uBAAuB,EACvB,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,EACvC,oDAAoD,EACpD,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,aAAsB,EACtB,KAAa;IAEb,MAAM,IAAI,GAAG;QACX,aAAa;QACb,KAAK;KACN,CAAA;IACD,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC,IAAI,CAC1E,CAAC,CAAC,EAAE,EAAE;QACJ,OAAO,CAAC,CAAA;IACV,CAAC,CACF,CAAA;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,oBAAoB,CAC5B,SAAS,CAAC,kBAAkB,EAC5B,uBAAuB,EACvB,EAAE,aAAa,EAAE,KAAK,EAAE,EACxB,oDAAoD,EACpD,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/src/apis/NFTApis.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getNftName = getNftName;
|
|
4
|
-
exports.getNftAddress = getNftAddress;
|
|
5
|
-
const constants_1 = require("../common/constants");
|
|
6
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
1
|
+
import { API_URL } from '../common/constants';
|
|
2
|
+
import { sendGetRequest } from '../utils/ApiUtils';
|
|
7
3
|
/**
|
|
8
4
|
* Get the name of an NFT collection
|
|
9
5
|
* @param {string} chainId https://chainlist.org/
|
|
@@ -14,8 +10,8 @@ const ApiUtils_1 = require("../utils/ApiUtils");
|
|
|
14
10
|
* "name": "Anatomy Science Ape Club"
|
|
15
11
|
* }
|
|
16
12
|
*/
|
|
17
|
-
async function getNftName(chainId, nftAddress) {
|
|
18
|
-
return await
|
|
13
|
+
export async function getNftName(chainId, nftAddress) {
|
|
14
|
+
return await sendGetRequest(API_URL, `asset/nft/${chainId}/${nftAddress}`);
|
|
19
15
|
}
|
|
20
16
|
/**
|
|
21
17
|
* Get the address and chainId of an NFT collection
|
|
@@ -27,7 +23,7 @@ async function getNftName(chainId, nftAddress) {
|
|
|
27
23
|
* "chain": "1"
|
|
28
24
|
* }
|
|
29
25
|
*/
|
|
30
|
-
async function getNftAddress(name) {
|
|
31
|
-
return await
|
|
26
|
+
export async function getNftAddress(name) {
|
|
27
|
+
return await sendGetRequest(API_URL, `asset/nft?name=${name}`);
|
|
32
28
|
}
|
|
33
29
|
//# sourceMappingURL=NFTApis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NFTApis.js","sourceRoot":"","sources":["../../../src/apis/NFTApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NFTApis.js","sourceRoot":"","sources":["../../../src/apis/NFTApis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAe,EACf,UAAkB;IAElB,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE,aAAa,OAAO,IAAI,UAAU,EAAE,CAAC,CAAA;AAC5E,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAY;IAC9C,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE,kBAAkB,IAAI,EAAE,CAAC,CAAA;AAChE,CAAC"}
|
|
@@ -1,44 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.getOpsOfWallet = getOpsOfWallet;
|
|
7
|
-
exports.getOps = getOps;
|
|
8
|
-
exports.deleteOp = deleteOp;
|
|
9
|
-
exports.signOp = signOp;
|
|
10
|
-
exports.executeOp = executeOp;
|
|
11
|
-
exports.estimateOp = estimateOp;
|
|
12
|
-
exports.scheduleOp = scheduleOp;
|
|
13
|
-
const constants_1 = require("../common/constants");
|
|
14
|
-
const data_1 = require("../data");
|
|
15
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
16
|
-
async function createOp(op) {
|
|
17
|
-
return (await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'operation', { ...op })).opId;
|
|
1
|
+
import { API_URL } from '../common/constants';
|
|
2
|
+
import { OperationStatus } from '../data';
|
|
3
|
+
import { sendDeleteRequest, sendGetRequest, sendPostRequest, } from '../utils/ApiUtils';
|
|
4
|
+
export async function createOp(op) {
|
|
5
|
+
return (await sendPostRequest(API_URL, 'operation', { ...op })).opId;
|
|
18
6
|
}
|
|
19
|
-
async function getOpsOfGroup(groupId, chainId, status) {
|
|
20
|
-
const endpoint = status ===
|
|
7
|
+
export async function getOpsOfGroup(groupId, chainId, status) {
|
|
8
|
+
const endpoint = status === OperationStatus.ALL
|
|
21
9
|
? `operation/group/${groupId}/${chainId}`
|
|
22
10
|
: `operation/group/${groupId}/chain/${chainId}?status=${status}`;
|
|
23
|
-
return (await
|
|
11
|
+
return (await sendGetRequest(API_URL, endpoint)).operations;
|
|
24
12
|
}
|
|
25
|
-
async function getOpsOfWallet(walletAddr, chainId, status) {
|
|
13
|
+
export async function getOpsOfWallet(walletAddr, chainId, status) {
|
|
26
14
|
const endpoint = status
|
|
27
15
|
? `operation/wallet/${walletAddr}/chain/${chainId}?status=${status}`
|
|
28
16
|
: `operation/wallet/${walletAddr}/chain/${chainId}`;
|
|
29
|
-
return (await
|
|
17
|
+
return (await sendGetRequest(API_URL, endpoint)).operations;
|
|
30
18
|
}
|
|
31
|
-
async function getOps(opIds, chainId) {
|
|
32
|
-
return (await
|
|
19
|
+
export async function getOps(opIds, chainId) {
|
|
20
|
+
return (await sendPostRequest(API_URL, 'operation/get-operations', {
|
|
33
21
|
opIds,
|
|
34
22
|
chainId,
|
|
35
23
|
})).operations;
|
|
36
24
|
}
|
|
37
|
-
async function deleteOp(opId, chainId) {
|
|
38
|
-
await
|
|
25
|
+
export async function deleteOp(opId, chainId) {
|
|
26
|
+
await sendDeleteRequest(API_URL, `operation/${opId}/chain/${chainId}`);
|
|
39
27
|
}
|
|
40
|
-
async function signOp(opId, chainId, signature, signedBy, threshold) {
|
|
41
|
-
await
|
|
28
|
+
export async function signOp(opId, chainId, signature, signedBy, threshold) {
|
|
29
|
+
await sendPostRequest(API_URL, 'operation/sign', {
|
|
42
30
|
opId,
|
|
43
31
|
chainId,
|
|
44
32
|
signature,
|
|
@@ -46,21 +34,21 @@ async function signOp(opId, chainId, signature, signedBy, threshold) {
|
|
|
46
34
|
threshold,
|
|
47
35
|
});
|
|
48
36
|
}
|
|
49
|
-
async function executeOp(executeOpInput) {
|
|
50
|
-
return await
|
|
37
|
+
export async function executeOp(executeOpInput) {
|
|
38
|
+
return await sendPostRequest(API_URL, 'operation/execute', executeOpInput);
|
|
51
39
|
}
|
|
52
|
-
async function estimateOp(estimateOpInput) {
|
|
53
|
-
return await
|
|
40
|
+
export async function estimateOp(estimateOpInput) {
|
|
41
|
+
return await sendPostRequest(API_URL, 'operation/estimate', estimateOpInput);
|
|
54
42
|
}
|
|
55
|
-
async function scheduleOp(scheduleOpInput) {
|
|
56
|
-
await
|
|
43
|
+
export async function scheduleOp(scheduleOpInput) {
|
|
44
|
+
await sendPostRequest(API_URL, 'operation/schedule', scheduleOpInput);
|
|
57
45
|
}
|
|
58
|
-
const getFullReceipt = async (opId, chainId, userOpHash) => {
|
|
46
|
+
export const getFullReceipt = async (opId, chainId, userOpHash) => {
|
|
59
47
|
const retries = 20;
|
|
60
48
|
let result;
|
|
61
49
|
for (let i = 0; i < retries; i++) {
|
|
62
50
|
try {
|
|
63
|
-
result = await
|
|
51
|
+
result = await sendGetRequest(API_URL, `operation/${opId}/chain/${chainId}/receipt?userOpHash=${userOpHash}`);
|
|
64
52
|
if (result.status === 'included') {
|
|
65
53
|
break;
|
|
66
54
|
}
|
|
@@ -82,9 +70,7 @@ const getFullReceipt = async (opId, chainId, userOpHash) => {
|
|
|
82
70
|
...result.receipt,
|
|
83
71
|
};
|
|
84
72
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `operation/chain/${chainId}/gas-price`);
|
|
73
|
+
export const getGasPrice = async (chainId) => {
|
|
74
|
+
return await sendGetRequest(API_URL, `operation/chain/${chainId}/gas-price`);
|
|
88
75
|
};
|
|
89
|
-
exports.getGasPrice = getGasPrice;
|
|
90
76
|
//# sourceMappingURL=OperationApis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationApis.js","sourceRoot":"","sources":["../../../src/apis/OperationApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OperationApis.js","sourceRoot":"","sources":["../../../src/apis/OperationApis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,OAAO,EAAa,eAAe,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAS1B,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,EAAa;IAC1C,OAAO,CAAC,MAAM,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AACtE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAY,EACZ,OAAe,EACf,MAAuB;IAEvB,MAAM,QAAQ,GACZ,MAAM,KAAK,eAAe,CAAC,GAAG;QAC5B,CAAC,CAAC,m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;IAClC,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE,mBAAmB,OAAO,YAAY,CAAC,CAAA;AAC9E,CAAC,CAAA"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const constants_1 = require("../common/constants");
|
|
5
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
6
|
-
async function addTransaction(chainId, timestamp, txid, transaction, paymasterType, sponsorAddress) {
|
|
1
|
+
import { DASHBOARD_API_URL } from '../common/constants';
|
|
2
|
+
import { sendPostRequest } from '../utils/ApiUtils';
|
|
3
|
+
export async function addTransaction(chainId, timestamp, txid, transaction, paymasterType, sponsorAddress) {
|
|
7
4
|
try {
|
|
8
|
-
return await
|
|
5
|
+
return await sendPostRequest(DASHBOARD_API_URL, 'paymasters/add-transaction', {
|
|
9
6
|
chain: chainId,
|
|
10
7
|
sponsorAddress,
|
|
11
8
|
type: paymasterType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymasterApis.js","sourceRoot":"","sources":["../../../src/apis/PaymasterApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PaymasterApis.js","sourceRoot":"","sources":["../../../src/apis/PaymasterApis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAUnD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAe,EACf,SAAiB,EACjB,IAAI,EACJ,WAAiC,EACjC,aAA4B,EAC5B,cAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,MAAM,eAAe,CAC1B,iBAAiB,EACjB,4BAA4B,EAC5B;YACE,KAAK,EAAE,OAAO;YACd,cAAc;YACd,IAAI,EAAE,aAAa;YACnB,SAAS;YACT,WAAW;YACX,IAAI;SACL,CACF,CAAA;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,WAAW;IACb,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.get1InchAllowance = get1InchAllowance;
|
|
5
|
-
exports.get1InchApproveTx = get1InchApproveTx;
|
|
6
|
-
const constants_1 = require("../common/constants");
|
|
7
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
8
|
-
async function get1InchSwapTx(chainId, src, dst, amount, from, slippage, disableEstimate, allowPartialFill) {
|
|
1
|
+
import { API_URL } from '../common/constants';
|
|
2
|
+
import { sendGetRequest } from '../utils/ApiUtils';
|
|
3
|
+
export async function get1InchSwapTx(chainId, src, dst, amount, from, slippage, disableEstimate, allowPartialFill) {
|
|
9
4
|
const params = new URLSearchParams({
|
|
10
5
|
src,
|
|
11
6
|
dst,
|
|
@@ -15,27 +10,27 @@ async function get1InchSwapTx(chainId, src, dst, amount, from, slippage, disable
|
|
|
15
10
|
disableEstimate,
|
|
16
11
|
allowPartialFill,
|
|
17
12
|
}).toString();
|
|
18
|
-
const res = await
|
|
13
|
+
const res = await sendGetRequest(API_URL, `swap/${chainId}/swap/?${params}`);
|
|
19
14
|
return {
|
|
20
15
|
to: res.tx.to,
|
|
21
16
|
value: Number(res.tx.value),
|
|
22
17
|
data: res.tx.data,
|
|
23
18
|
};
|
|
24
19
|
}
|
|
25
|
-
async function get1InchAllowance(chainId, tokenAddress, walletAddress) {
|
|
20
|
+
export async function get1InchAllowance(chainId, tokenAddress, walletAddress) {
|
|
26
21
|
const params = new URLSearchParams({
|
|
27
22
|
tokenAddress,
|
|
28
23
|
walletAddress,
|
|
29
24
|
}).toString();
|
|
30
|
-
const res = await
|
|
25
|
+
const res = await sendGetRequest(API_URL, `swap/${chainId}/approve/allowance/?${params}`);
|
|
31
26
|
return Number(res['allowance']);
|
|
32
27
|
}
|
|
33
|
-
async function get1InchApproveTx(chainId, tokenAddress, amount) {
|
|
28
|
+
export async function get1InchApproveTx(chainId, tokenAddress, amount) {
|
|
34
29
|
const params = new URLSearchParams({
|
|
35
30
|
tokenAddress,
|
|
36
31
|
amount,
|
|
37
32
|
}).toString();
|
|
38
|
-
const res = await
|
|
33
|
+
const res = await sendGetRequest(API_URL, `swap/${chainId}/approve/transaction/?${params}`);
|
|
39
34
|
return {
|
|
40
35
|
to: res.to,
|
|
41
36
|
value: Number(res.value),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapApis.js","sourceRoot":"","sources":["../../../src/apis/SwapApis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SwapApis.js","sourceRoot":"","sources":["../../../src/apis/SwapApis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAe,EACf,GAAW,EACX,GAAW,EACX,MAAc,EACd,IAAY,EACZ,QAAgB,EAChB,eAAuB,EACvB,gBAAwB;IAExB,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,GAAG;QACH,GAAG;QACH,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,eAAe;QACf,gBAAgB;KACjB,CAAC,CAAC,QAAQ,EAAE,CAAA;IACb,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,QAAQ,OAAO,UAAU,MAAM,EAAE,CAAC,CAAA;IAC5E,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE;QACb,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;QAC3B,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI;KAClB,CAAA;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,YAAoB,EACpB,aAAqB;IAErB,MAAM,MAAM,GAAG,IAAI,eA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