@funkit/core 1.0.12 → 1.0.14

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.
Files changed (42) hide show
  1. package/dist/src/apis/index.d.ts +0 -6
  2. package/dist/src/apis/index.js +0 -6
  3. package/dist/src/apis/index.js.map +1 -1
  4. package/dist/src/apis/types.d.ts +0 -5
  5. package/dist/src/apis/types.js.map +1 -1
  6. package/dist/src/utils/ChainUtils.js +27 -5
  7. package/dist/src/utils/ChainUtils.js.map +1 -1
  8. package/dist/src/utils/index.d.ts +0 -1
  9. package/dist/src/utils/index.js +0 -1
  10. package/dist/src/utils/index.js.map +1 -1
  11. package/dist/src/viem/Converter.d.ts +16 -16
  12. package/dist/src/wallet/FunWallet.d.ts +7 -6
  13. package/dist/src/wallet/FunWallet.js +60 -20
  14. package/dist/src/wallet/FunWallet.js.map +1 -1
  15. package/package.json +96 -96
  16. package/dist/src/apis/AssetApis.d.ts +0 -89
  17. package/dist/src/apis/AssetApis.js +0 -110
  18. package/dist/src/apis/AssetApis.js.map +0 -1
  19. package/dist/src/apis/CheckoutApis.d.ts +0 -55
  20. package/dist/src/apis/CheckoutApis.js +0 -174
  21. package/dist/src/apis/CheckoutApis.js.map +0 -1
  22. package/dist/src/apis/FaucetApis.d.ts +0 -1
  23. package/dist/src/apis/FaucetApis.js +0 -10
  24. package/dist/src/apis/FaucetApis.js.map +0 -1
  25. package/dist/src/apis/MeshApis.d.ts +0 -44
  26. package/dist/src/apis/MeshApis.js +0 -109
  27. package/dist/src/apis/MeshApis.js.map +0 -1
  28. package/dist/src/apis/OnOffRampApis.d.ts +0 -38
  29. package/dist/src/apis/OnOffRampApis.js +0 -74
  30. package/dist/src/apis/OnOffRampApis.js.map +0 -1
  31. package/dist/src/apis/OnOffRampUtils.d.ts +0 -2
  32. package/dist/src/apis/OnOffRampUtils.js +0 -23
  33. package/dist/src/apis/OnOffRampUtils.js.map +0 -1
  34. package/dist/src/apis/SupportApis.d.ts +0 -6
  35. package/dist/src/apis/SupportApis.js +0 -16
  36. package/dist/src/apis/SupportApis.js.map +0 -1
  37. package/dist/src/apis/TurnkeyApis.d.ts +0 -3
  38. package/dist/src/apis/TurnkeyApis.js +0 -19
  39. package/dist/src/apis/TurnkeyApis.js.map +0 -1
  40. package/dist/src/utils/AssetUtils.d.ts +0 -9
  41. package/dist/src/utils/AssetUtils.js +0 -48
  42. package/dist/src/utils/AssetUtils.js.map +0 -1
package/package.json CHANGED
@@ -1,97 +1,97 @@
1
1
  {
2
- "name": "@funkit/core",
3
- "version": "1.0.12",
4
- "description": "Funkit core SDK provides feature-rich and extensible smart wallets built on account abstraction",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
- "scripts": {
11
- "build": "rm -rf dist && tsc",
12
- "build:watch": "rm -rf dist && tsc -w",
13
- "prepare": "pnpm run build",
14
- "test": "ts-mocha --exit tests/tenderly/*.ts --exit",
15
- "test-tenderly": "ts-mocha --exit tests/tenderly/*.ts",
16
- "test-aws": "env ts-mocha",
17
- "test-goerli": "env ts-mocha --exit tests/goerli/*.ts",
18
- "local-test-tenderly": "env NODE_ENV=local ts-mocha --exit tests/tenderly/*.ts",
19
- "local-test-goerli": "env NODE_ENV=local ts-mocha --exit tests/goerli/*.ts",
20
- "staging-test-tenderly": "env NODE_ENV=staging ts-mocha --exit tests/tenderly/*.ts",
21
- "staging-test-goerli": "env NODE_ENV=staging ts-mocha --exit tests/goerli/*.ts",
22
- "staging-test-arbitrum": "env NODE_ENV=staging ts-mocha --exit tests/arbitrum/*.ts",
23
- "staging-test-optimism": "env NODE_ENV=staging ts-mocha --exit tests/optimism/*.ts",
24
- "staging-test-polygon": "env NODE_ENV=staging ts-mocha --exit tests/polygon/*.ts",
25
- "load": "node test/loader.js",
26
- "format": "prettier --write .",
27
- "lint": "eslint --ext .ts,.tsx './**/*.{ts,tsx}'",
28
- "lint:fix": "eslint --ext .ts,.tsx './**/*.{ts,tsx}' --fix",
29
- "add-token": "ts-node tests/addToken.ts",
30
- "fund-tenderly-account": "ts-node tests/scripts/fundAccount.ts"
31
- },
32
- "author": "https://fun.xyz/",
33
- "license": "MIT",
34
- "dependencies": {
35
- "@aws-sdk/client-secrets-manager": "^3.315.0",
36
- "@ethersproject/abi": "^5.7.0",
37
- "@ethersproject/contracts": "^5.7.0",
38
- "@ethersproject/providers": "^5.7.2",
39
- "@lifeomic/attempt": "^3.0.3",
40
- "@uniswap/sdk": "^3.0.3",
41
- "@uniswap/sdk-core": "^4.2.0",
42
- "@uniswap/v3-core": "1.0.1",
43
- "@uniswap/v3-sdk": "^3.11.0",
44
- "abitype": "^0.10.2",
45
- "big.js": "^6.2.1",
46
- "dotenv": "^16.0.3",
47
- "ethers": "5.7.2",
48
- "node-fetch": "^2.6.11",
49
- "uuid": "^9.0.0",
50
- "viem": "^2.9.2"
51
- },
52
- "devDependencies": {
53
- "@types/big.js": "^6.2.2",
54
- "@types/chai": "^4.3.5",
55
- "@types/mocha": "^10.0.1",
56
- "@types/node-fetch": "^2.6.4",
57
- "@types/uuid": "^9.0.1",
58
- "@typescript-eslint/eslint-plugin": "^5.59.7",
59
- "@typescript-eslint/parser": "^5.59.7",
60
- "chai": "^4.3.7",
61
- "eslint": "^8.41.0",
62
- "eslint-config-prettier": "^8.8.0",
63
- "eslint-plugin-import": "^2.27.5",
64
- "eslint-plugin-prettier": "^4.2.1",
65
- "eslint-plugin-unused-imports": "^2.0.0",
66
- "husky": "^8.0.3",
67
- "mocha": "^10.2.0",
68
- "prettier": "^2.8.8",
69
- "ts-mocha": "^10.0.0",
70
- "ts-node": "^10.9.1",
71
- "typescript": "^5.4.3"
72
- },
73
- "repository": {
74
- "type": "git",
75
- "url": "git+https://github.com/fun-xyz/funkit.git",
76
- "directory": "packages/core"
77
- },
78
- "keywords": [
79
- "Fun Wallet",
80
- "Ethereum",
81
- "Account Abstraction",
82
- "SDK"
83
- ],
84
- "files": [
85
- "dist/src",
86
- "dist/index.d.ts",
87
- "dist/index.js",
88
- "dist/index.js.map",
89
- "dist/fetch-polyfill.d.ts",
90
- "dist/fetch-polyfill.js",
91
- "dist/fetch-polyfill.js.map"
92
- ],
93
- "bugs": {
94
- "url": "https://github.com/fun-xyz/funkit-core/issues"
95
- },
96
- "homepage": "https://github.com/fun-xyz/funkit-core"
97
- }
2
+ "name": "@funkit/core",
3
+ "version": "1.0.14",
4
+ "description": "Funkit core SDK provides feature-rich and extensible smart wallets built on account abstraction",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "author": "https://fun.xyz/",
11
+ "license": "MIT",
12
+ "dependencies": {
13
+ "@aws-sdk/client-secrets-manager": "^3.315.0",
14
+ "@ethersproject/abi": "^5.7.0",
15
+ "@ethersproject/contracts": "^5.7.0",
16
+ "@ethersproject/providers": "^5.7.2",
17
+ "@lifeomic/attempt": "^3.0.3",
18
+ "@uniswap/sdk": "^3.0.3",
19
+ "@uniswap/sdk-core": "^4.2.0",
20
+ "@uniswap/v3-core": "1.0.1",
21
+ "@uniswap/v3-sdk": "^3.11.0",
22
+ "abitype": "^0.10.2",
23
+ "big.js": "^6.2.1",
24
+ "dotenv": "^16.0.3",
25
+ "ethers": "5.7.2",
26
+ "node-fetch": "^2.6.11",
27
+ "uuid": "^9.0.0",
28
+ "viem": "^2.9.2",
29
+ "@funkit/api-base": "0.0.3"
30
+ },
31
+ "devDependencies": {
32
+ "@types/big.js": "^6.2.2",
33
+ "@types/chai": "^4.3.5",
34
+ "@types/mocha": "^10.0.1",
35
+ "@types/node-fetch": "^2.6.4",
36
+ "@types/uuid": "^9.0.1",
37
+ "@typescript-eslint/eslint-plugin": "^5.59.7",
38
+ "@typescript-eslint/parser": "^5.59.7",
39
+ "chai": "^4.3.7",
40
+ "eslint": "^8.41.0",
41
+ "eslint-config-prettier": "^8.8.0",
42
+ "eslint-plugin-import": "^2.27.5",
43
+ "eslint-plugin-prettier": "^4.2.1",
44
+ "eslint-plugin-unused-imports": "^2.0.0",
45
+ "husky": "^8.0.3",
46
+ "mocha": "^10.2.0",
47
+ "prettier": "^2.8.8",
48
+ "ts-mocha": "^10.0.0",
49
+ "ts-node": "^10.9.1",
50
+ "typescript": "^5.4.3"
51
+ },
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/fun-xyz/funkit.git",
55
+ "directory": "packages/core"
56
+ },
57
+ "keywords": [
58
+ "Fun Wallet",
59
+ "Ethereum",
60
+ "Account Abstraction",
61
+ "SDK"
62
+ ],
63
+ "files": [
64
+ "dist/src",
65
+ "dist/index.d.ts",
66
+ "dist/index.js",
67
+ "dist/index.js.map",
68
+ "dist/fetch-polyfill.d.ts",
69
+ "dist/fetch-polyfill.js",
70
+ "dist/fetch-polyfill.js.map"
71
+ ],
72
+ "bugs": {
73
+ "url": "https://github.com/fun-xyz/funkit-core/issues"
74
+ },
75
+ "homepage": "https://github.com/fun-xyz/funkit-core",
76
+ "scripts": {
77
+ "build": "rm -rf dist && tsc",
78
+ "build:watch": "rm -rf dist && tsc -w",
79
+ "test": "ts-mocha --exit tests/tenderly/*.ts --exit",
80
+ "test-tenderly": "ts-mocha --exit tests/tenderly/*.ts",
81
+ "test-aws": "env ts-mocha",
82
+ "test-goerli": "env ts-mocha --exit tests/goerli/*.ts",
83
+ "local-test-tenderly": "env NODE_ENV=local ts-mocha --exit tests/tenderly/*.ts",
84
+ "local-test-goerli": "env NODE_ENV=local ts-mocha --exit tests/goerli/*.ts",
85
+ "staging-test-tenderly": "env NODE_ENV=staging ts-mocha --exit tests/tenderly/*.ts",
86
+ "staging-test-goerli": "env NODE_ENV=staging ts-mocha --exit tests/goerli/*.ts",
87
+ "staging-test-arbitrum": "env NODE_ENV=staging ts-mocha --exit tests/arbitrum/*.ts",
88
+ "staging-test-optimism": "env NODE_ENV=staging ts-mocha --exit tests/optimism/*.ts",
89
+ "staging-test-polygon": "env NODE_ENV=staging ts-mocha --exit tests/polygon/*.ts",
90
+ "load": "node test/loader.js",
91
+ "format": "prettier --write .",
92
+ "lint": "eslint --ext .ts,.tsx './**/*.{ts,tsx}'",
93
+ "lint:fix": "eslint --ext .ts,.tsx './**/*.{ts,tsx}' --fix",
94
+ "add-token": "ts-node tests/addToken.ts",
95
+ "fund-tenderly-account": "ts-node tests/scripts/fundAccount.ts"
96
+ }
97
+ }
@@ -1,89 +0,0 @@
1
- /**
2
- * Get all tokens for a specific chain
3
- * @param {string} chainId https://chainlist.org/
4
- * @param {string} holderAddr
5
- * @param {string} onlyVerifiedTokens If true, only return alchemy tokens that are verified(filters spam)
6
- * @returns JSON
7
- * {
8
- * "0xTokenAddress": {
9
- * "tokenBalance": "0x00001",
10
- * "symbol": "USDC",
11
- * "decimals": 6,
12
- * "logo": "https://static.alchemyapi.io/images/assets/3408.png",
13
- * "price": 1.0001,
14
- * }
15
- * }
16
- */
17
- export declare function getTokens(chainId: string, holderAddr: string, onlyVerifiedTokens: boolean): Promise<any>;
18
- /**
19
- * Calls the fun api server to get all the NFTs owned by the holder
20
- * @param {string} chainId From https://chainlist.org/
21
- * @param {string} holderAddr Address of holder
22
- * @returns array
23
- * [
24
- * {
25
- * "address": "string",
26
- * "token_id": "string",
27
- * "floor_price": "string",
28
- * }
29
- * ]
30
- */
31
- export declare function getNFTs(chainId: string, holderAddr: string): Promise<any>;
32
- /**
33
- * Calls the fun api server to get all the NFTs owned by the holder
34
- * @param {string} holderAddr Address of holder
35
- * @returns array
36
- * {
37
- * "1" : [{
38
- * "address": "string",
39
- * "token_id": "string",
40
- * "floor_price": "string",
41
- * }],
42
- * }
43
- */
44
- export declare function getAllNFTs(holderAddr: string): Promise<any>;
45
- /**
46
- * Get all tokens for a specific chain
47
- * @param {string} holderAddr
48
- * @param {string} onlyVerifiedTokens If true, only return alchemy tokens that are verified(filters spam)
49
- * @returns JSON
50
- * {
51
- * 1: {
52
- * "0xTokenAddress": {
53
- * "tokenBalance": "0x00001",
54
- * "symbol": "USDC",
55
- * "decimals": 6,
56
- * "logo": "https://static.alchemyapi.io/images/assets/3408.png",
57
- * "price": 1.0001,
58
- * }
59
- * }
60
- * }
61
- */
62
- export declare function getAllTokens(holderAddr: string, onlyVerifiedTokens: boolean): Promise<any>;
63
- /**
64
- * Get all lido withdrawal request ids for all chains
65
- * @param {string} chainId https://chainlist.org/ ie "1" for ethereum
66
- * @param {string} holderAddr Address of holder
67
- * @returns [readyToWithdrawRequestIds, notReadyToWithdrawRequestIds]
68
- * [
69
- * [
70
- * 123,
71
- * 124,
72
- * ],
73
- * [
74
- * 412
75
- * 413
76
- * ]
77
- * ]
78
- */
79
- export declare function getLidoWithdrawals(chainId: string, holderAddr: string): Promise<any>;
80
- /**
81
- * Gets the estimated dollar unit price of a tokenAddress for checkout
82
- * @param chainId https://chainlist.org/ ie "1" for ethereum
83
- * @param assetTokenAddress tokenAddress of the asset
84
- */
85
- export declare function getAssetPriceInfoForCheckout(chainId: string, assetTokenAddress: string, apiKey?: string): Promise<{
86
- unitPrice: number;
87
- amount: number;
88
- total: number;
89
- }>;
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAssetPriceInfoForCheckout = exports.getLidoWithdrawals = exports.getAllTokens = exports.getAllNFTs = exports.getNFTs = exports.getTokens = void 0;
4
- const constants_1 = require("../common/constants");
5
- const ApiUtils_1 = require("../utils/ApiUtils");
6
- /**
7
- * Get all tokens for a specific chain
8
- * @param {string} chainId https://chainlist.org/
9
- * @param {string} holderAddr
10
- * @param {string} onlyVerifiedTokens If true, only return alchemy tokens that are verified(filters spam)
11
- * @returns JSON
12
- * {
13
- * "0xTokenAddress": {
14
- * "tokenBalance": "0x00001",
15
- * "symbol": "USDC",
16
- * "decimals": 6,
17
- * "logo": "https://static.alchemyapi.io/images/assets/3408.png",
18
- * "price": 1.0001,
19
- * }
20
- * }
21
- */
22
- async function getTokens(chainId, holderAddr, onlyVerifiedTokens) {
23
- return await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `assets/erc20s/${holderAddr}/${chainId}?onlyVerifiedTokens=${onlyVerifiedTokens}`);
24
- }
25
- exports.getTokens = getTokens;
26
- /**
27
- * Calls the fun api server to get all the NFTs owned by the holder
28
- * @param {string} chainId From https://chainlist.org/
29
- * @param {string} holderAddr Address of holder
30
- * @returns array
31
- * [
32
- * {
33
- * "address": "string",
34
- * "token_id": "string",
35
- * "floor_price": "string",
36
- * }
37
- * ]
38
- */
39
- async function getNFTs(chainId, holderAddr) {
40
- return await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `assets/nfts/${holderAddr}/${chainId}`);
41
- }
42
- exports.getNFTs = getNFTs;
43
- /**
44
- * Calls the fun api server to get all the NFTs owned by the holder
45
- * @param {string} holderAddr Address of holder
46
- * @returns array
47
- * {
48
- * "1" : [{
49
- * "address": "string",
50
- * "token_id": "string",
51
- * "floor_price": "string",
52
- * }],
53
- * }
54
- */
55
- async function getAllNFTs(holderAddr) {
56
- return await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `assets/nfts/${holderAddr}`);
57
- }
58
- exports.getAllNFTs = getAllNFTs;
59
- /**
60
- * Get all tokens for a specific chain
61
- * @param {string} holderAddr
62
- * @param {string} onlyVerifiedTokens If true, only return alchemy tokens that are verified(filters spam)
63
- * @returns JSON
64
- * {
65
- * 1: {
66
- * "0xTokenAddress": {
67
- * "tokenBalance": "0x00001",
68
- * "symbol": "USDC",
69
- * "decimals": 6,
70
- * "logo": "https://static.alchemyapi.io/images/assets/3408.png",
71
- * "price": 1.0001,
72
- * }
73
- * }
74
- * }
75
- */
76
- async function getAllTokens(holderAddr, onlyVerifiedTokens) {
77
- return await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `assets/erc20s/${holderAddr}?onlyVerifiedTokens=${onlyVerifiedTokens}`);
78
- }
79
- exports.getAllTokens = getAllTokens;
80
- /**
81
- * Get all lido withdrawal request ids for all chains
82
- * @param {string} chainId https://chainlist.org/ ie "1" for ethereum
83
- * @param {string} holderAddr Address of holder
84
- * @returns [readyToWithdrawRequestIds, notReadyToWithdrawRequestIds]
85
- * [
86
- * [
87
- * 123,
88
- * 124,
89
- * ],
90
- * [
91
- * 412
92
- * 413
93
- * ]
94
- * ]
95
- */
96
- async function getLidoWithdrawals(chainId, holderAddr) {
97
- return await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `assets/lido-withdrawals/${holderAddr}/${chainId}`);
98
- }
99
- exports.getLidoWithdrawals = getLidoWithdrawals;
100
- /**
101
- * Gets the estimated dollar unit price of a tokenAddress for checkout
102
- * @param chainId https://chainlist.org/ ie "1" for ethereum
103
- * @param assetTokenAddress tokenAddress of the asset
104
- */
105
- async function getAssetPriceInfoForCheckout(chainId, assetTokenAddress, apiKey) {
106
- const priceInfo = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `asset/erc20/price/${chainId}/${assetTokenAddress}`, apiKey, { maxAttempts: 2 });
107
- return priceInfo;
108
- }
109
- exports.getAssetPriceInfoForCheckout = getAssetPriceInfoForCheckout;
110
- //# sourceMappingURL=AssetApis.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AssetApis.js","sourceRoot":"","sources":["../../../src/apis/AssetApis.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAC7C,gDAAkD;AAElD;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,SAAS,CAC7B,OAAe,EACf,UAAkB,EAClB,kBAA2B;IAE3B,OAAO,MAAM,IAAA,yBAAc,EACzB,mBAAO,EACP,iBAAiB,UAAU,IAAI,OAAO,uBAAuB,kBAAkB,EAAE,CAClF,CAAA;AACH,CAAC;AATD,8BASC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,OAAO,CAC3B,OAAe,EACf,UAAkB;IAElB,OAAO,MAAM,IAAA,yBAAc,EAAC,mBAAO,EAAE,eAAe,UAAU,IAAI,OAAO,EAAE,CAAC,CAAA;AAC9E,CAAC;AALD,0BAKC;AAED;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,UAAU,CAAC,UAAkB;IACjD,OAAO,MAAM,IAAA,yBAAc,EAAC,mBAAO,EAAE,eAAe,UAAU,EAAE,CAAC,CAAA;AACnE,CAAC;AAFD,gCAEC;AAED;;;;;;;;;;;;;;;;GAgBG;AACI,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,kBAA2B;IAE3B,OAAO,MAAM,IAAA,yBAAc,EACzB,mBAAO,EACP,iBAAiB,UAAU,uBAAuB,kBAAkB,EAAE,CACvE,CAAA;AACH,CAAC;AARD,oCAQC;AAED;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,kBAAkB,CACtC,OAAe,EACf,UAAkB;IAElB,OAAO,MAAM,IAAA,yBAAc,EACzB,mBAAO,EACP,2BAA2B,UAAU,IAAI,OAAO,EAAE,CACnD,CAAA;AACH,CAAC;AARD,gDAQC;AAED;;;;GAIG;AACI,KAAK,UAAU,4BAA4B,CAChD,OAAe,EACf,iBAAyB,EACzB,MAAe;IAMf,MAAM,SAAS,GAAG,MAAM,IAAA,yBAAc,EACpC,mBAAO,EACP,qBAAqB,OAAO,IAAI,iBAAiB,EAAE,EACnD,MAAM,EACN,EAAE,WAAW,EAAE,CAAC,EAAE,CACnB,CAAA;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAhBD,oEAgBC"}
@@ -1,55 +0,0 @@
1
- import { Address } from 'viem';
2
- import { CheckoutCoreInitParams, CheckoutCoreQuoteParams, CheckoutCoreQuoteResponse, CheckoutHistoryItem, CheckoutRequestRefuelCoreParams, CheckoutRequestRefuelResponse, CheckoutTransferSponsorshipCoreParams, CheckoutTransferSponsorshipResponse } from './types';
3
- /**
4
- * Gets a checkout quote (estimation).
5
- * @param fromChainId The ID of the chain where funds will be provided from.
6
- * @param fromTokenAddress The asset to fund the checkout. This must be either a chain native token or an ERC-20, on the fromChainId.
7
- * @param toChainId The ID of the chain where the checkout operation is to be performed.
8
- * @param toTokenAddress The wanted asset for the checkout operation. This must be either a chain native token or an ERC-20, on the target chain.
9
- * @param toTokenAmount The amount of wanted asset for the checkout operation in base units.
10
- * @param expirationTimestampMs The amount of time (duration) from now before the checkout operation expires.
11
- * @param apiKey A valid fun api key.
12
- * @return {Promise<CheckoutCoreQuoteResponse>} The formatted quote object
13
- */
14
- export declare function getCheckoutQuote({ fromChainId, fromTokenAddress, toChainId, toTokenAddress, toTokenAmount, expirationTimestampMs, sponsorInitialTransferGasLimit, recipientAddr, needsRefuel, apiKey, }: CheckoutCoreQuoteParams): Promise<CheckoutCoreQuoteResponse>;
15
- /**
16
- * Initializes a checkout
17
- * @param userOp The checkout UserOp, signed.
18
- * @param quoteId The quoteId specific to the checkout.
19
- * @param apiKey A valid fun api key.
20
- * @return {Address} The generated deposit address
21
- */
22
- export declare function initializeCheckout({ userOp, quoteId, sourceOfFund, apiKey, clientMetadata, }: CheckoutCoreInitParams): Promise<Address>;
23
- /**
24
- * Gets a checkout given a depositAddress
25
- * @param depositAddress A unique deposit address associated with a backend checkout item.
26
- * @param apiKey A valid fun api key.
27
- * // TODO: Return interface
28
- * @returns The checkout object if exists. Otherwise, null.
29
- */
30
- export declare function getCheckoutByDepositAddress({ depositAddress, apiKey, }: {
31
- depositAddress: Address;
32
- apiKey: string;
33
- }): Promise<any>;
34
- /**
35
- * Gets all checkouts associated with a funWallet
36
- * @param funWalletAddress A funWallet address.
37
- * @param apiKey A valid fun api key.
38
- * @returns A list of checkout objects if exists. Otherwise, an empty array.
39
- */
40
- export declare function getCheckoutsByFunWalletAddress({ funWalletAddress, apiKey, }: {
41
- funWalletAddress: Address;
42
- apiKey: string;
43
- }): Promise<CheckoutHistoryItem[]>;
44
- /**
45
- * Gets all checkouts associated with a recipient address
46
- * @param recipientAddress A wallet address.
47
- * @param apiKey A valid fun api key.
48
- * @returns A list of checkout objects if exists. Otherwise, an empty array.
49
- */
50
- export declare function getCheckoutsByRecipientAddress({ recipientAddress, apiKey, }: {
51
- recipientAddress: Address;
52
- apiKey: string;
53
- }): Promise<CheckoutHistoryItem[]>;
54
- export declare function getPaymasterDataForCheckoutSponsoredTransfer({ depositAddress, transferUserOp, apiKey, }: CheckoutTransferSponsorshipCoreParams): Promise<CheckoutTransferSponsorshipResponse>;
55
- export declare function requestCheckoutRefuel({ signedTxData, depositAddress, apiKey, }: CheckoutRequestRefuelCoreParams): Promise<CheckoutRequestRefuelResponse>;
@@ -1,174 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.requestCheckoutRefuel = exports.getPaymasterDataForCheckoutSponsoredTransfer = exports.getCheckoutsByRecipientAddress = exports.getCheckoutsByFunWalletAddress = exports.getCheckoutByDepositAddress = exports.initializeCheckout = exports.getCheckoutQuote = void 0;
7
- const big_js_1 = __importDefault(require("big.js"));
8
- const viem_1 = require("viem");
9
- const constants_1 = require("../common/constants");
10
- const errors_1 = require("../errors");
11
- const ApiUtils_1 = require("../utils/ApiUtils");
12
- const CheckoutUtils_1 = require("../utils/CheckoutUtils");
13
- /**
14
- * Gets a checkout quote (estimation).
15
- * @param fromChainId The ID of the chain where funds will be provided from.
16
- * @param fromTokenAddress The asset to fund the checkout. This must be either a chain native token or an ERC-20, on the fromChainId.
17
- * @param toChainId The ID of the chain where the checkout operation is to be performed.
18
- * @param toTokenAddress The wanted asset for the checkout operation. This must be either a chain native token or an ERC-20, on the target chain.
19
- * @param toTokenAmount The amount of wanted asset for the checkout operation in base units.
20
- * @param expirationTimestampMs The amount of time (duration) from now before the checkout operation expires.
21
- * @param apiKey A valid fun api key.
22
- * @return {Promise<CheckoutCoreQuoteResponse>} The formatted quote object
23
- */
24
- async function getCheckoutQuote({ fromChainId, fromTokenAddress, toChainId, toTokenAddress, toTokenAmount, expirationTimestampMs, sponsorInitialTransferGasLimit, recipientAddr, needsRefuel, apiKey, }) {
25
- try {
26
- const toDecimals = await (0, CheckoutUtils_1.getDecimals)({
27
- chainId: toChainId,
28
- tokenAddress: toTokenAddress,
29
- });
30
- const toMultipler = 10 ** toDecimals;
31
- const toAmountBaseUnitBI = BigInt(Math.floor(toTokenAmount * toMultipler));
32
- const queryParams = {
33
- fromChainId,
34
- fromTokenAddress,
35
- toChainId,
36
- toTokenAddress,
37
- toAmountBaseUnit: toAmountBaseUnitBI.toString(),
38
- // Only pass in recipientAddr if specified
39
- ...((0, viem_1.isAddress)(recipientAddr || '') ? { recipientAddr } : {}),
40
- // Rounding nearest tenth second (instead of seconds) to better support backend quote caching feature
41
- // Reference: https://vintage-heaven-3cd.notion.site/API-Gateway-Caching-and-Pre-Warming-System-Draft-ee7909d9b85f43c793ce7bd2607bec02?pvs=4
42
- // Note: Rounding *down* instead of a regular round to safeguard against edge case of timing passing frontend range validation but failing backend range validation
43
- checkoutExpirationTimestampSeconds: (0, CheckoutUtils_1.roundToNearestBottomTenth)(Math.round((Date.now() + expirationTimestampMs) / 1000)).toString(),
44
- sponsorInitialTransferGasLimit,
45
- refuel: needsRefuel.toString(),
46
- };
47
- const searchParams = new URLSearchParams(queryParams);
48
- const url = `checkout/quote?${searchParams}`;
49
- const quoteRes = (await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, url, apiKey));
50
- const fromDecimals = await (0, CheckoutUtils_1.getDecimals)({
51
- chainId: fromChainId,
52
- tokenAddress: fromTokenAddress,
53
- });
54
- const fromMultipler = 10 ** fromDecimals;
55
- // Format the response for frontend usage
56
- return {
57
- quoteId: quoteRes.quoteId,
58
- fromTokenAddress: quoteRes.fromTokenAddress,
59
- estFeesUsd: quoteRes.estFeesUsd,
60
- estSubtotalUsd: quoteRes.estSubtotalUsd,
61
- estTotalUsd: quoteRes.estTotalUsd,
62
- estCheckoutTimeMs: quoteRes.estCheckoutTimeMs,
63
- estTotalFromAmountBaseUnit: quoteRes.estTotalFromAmountBaseUnit,
64
- estSubtotalFromAmountBaseUnit: quoteRes.estSubtotalFromAmountBaseUnit,
65
- estFeesFromAmountBaseUnit: quoteRes.estFeesFromAmountBaseUnit,
66
- // Added fields
67
- estFeesFromAmount: new big_js_1.default(quoteRes.estFeesFromAmountBaseUnit)
68
- .div(fromMultipler)
69
- .toString(),
70
- estSubtotalFromAmount: new big_js_1.default(quoteRes.estSubtotalFromAmountBaseUnit)
71
- .div(fromMultipler)
72
- .toString(),
73
- estTotalFromAmount: new big_js_1.default(quoteRes.estTotalFromAmountBaseUnit)
74
- .div(fromMultipler)
75
- .toString(),
76
- };
77
- }
78
- catch (err) {
79
- throw new Error(`An error occured trying to generate a checkout quote: ${err.message}`);
80
- }
81
- }
82
- exports.getCheckoutQuote = getCheckoutQuote;
83
- /**
84
- * Initializes a checkout
85
- * @param userOp The checkout UserOp, signed.
86
- * @param quoteId The quoteId specific to the checkout.
87
- * @param apiKey A valid fun api key.
88
- * @return {Address} The generated deposit address
89
- */
90
- async function initializeCheckout({ userOp, quoteId, sourceOfFund, apiKey, clientMetadata, }) {
91
- const body = {
92
- ...(userOp ? { userOp } : {}),
93
- quoteId,
94
- sourceOfFund,
95
- salt: (0, CheckoutUtils_1.generateRandomCheckoutSalt)(),
96
- clientMetadata,
97
- };
98
- const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'checkout', body, apiKey);
99
- if (!res?.depositAddr) {
100
- throw new errors_1.ResourceNotFoundError(errors_1.ErrorCode.CheckoutInitDepositAddrNotFound, 'Unable to initialize checkout', body, '', 'https://docs.fun.xyz');
101
- }
102
- return res.depositAddr;
103
- }
104
- exports.initializeCheckout = initializeCheckout;
105
- /**
106
- * Gets a checkout given a depositAddress
107
- * @param depositAddress A unique deposit address associated with a backend checkout item.
108
- * @param apiKey A valid fun api key.
109
- * // TODO: Return interface
110
- * @returns The checkout object if exists. Otherwise, null.
111
- */
112
- async function getCheckoutByDepositAddress({ depositAddress, apiKey, }) {
113
- try {
114
- return await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `checkout/${depositAddress}`, apiKey);
115
- }
116
- catch (err) {
117
- if (err instanceof errors_1.ResourceNotFoundError) {
118
- return null;
119
- }
120
- throw err;
121
- }
122
- }
123
- exports.getCheckoutByDepositAddress = getCheckoutByDepositAddress;
124
- /**
125
- * Gets all checkouts associated with a funWallet
126
- * @param funWalletAddress A funWallet address.
127
- * @param apiKey A valid fun api key.
128
- * @returns A list of checkout objects if exists. Otherwise, an empty array.
129
- */
130
- async function getCheckoutsByFunWalletAddress({ funWalletAddress, apiKey, }) {
131
- const url = `checkout/fun-wallet/${funWalletAddress}`;
132
- const res = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, url, apiKey);
133
- return res || [];
134
- }
135
- exports.getCheckoutsByFunWalletAddress = getCheckoutsByFunWalletAddress;
136
- /**
137
- * Gets all checkouts associated with a recipient address
138
- * @param recipientAddress A wallet address.
139
- * @param apiKey A valid fun api key.
140
- * @returns A list of checkout objects if exists. Otherwise, an empty array.
141
- */
142
- async function getCheckoutsByRecipientAddress({ recipientAddress, apiKey, }) {
143
- const url = `checkout/recipient/${recipientAddress}`;
144
- const res = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, url, apiKey);
145
- return res || [];
146
- }
147
- exports.getCheckoutsByRecipientAddress = getCheckoutsByRecipientAddress;
148
- async function getPaymasterDataForCheckoutSponsoredTransfer({ depositAddress, transferUserOp, apiKey, }) {
149
- const body = {
150
- depositAddress,
151
- userOp: transferUserOp,
152
- };
153
- const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'checkout/sponsor-transfer', body, apiKey);
154
- if (!res) {
155
- // TODO: Better error handling
156
- throw new Error('Unable to get sponsorship information');
157
- }
158
- return res;
159
- }
160
- exports.getPaymasterDataForCheckoutSponsoredTransfer = getPaymasterDataForCheckoutSponsoredTransfer;
161
- async function requestCheckoutRefuel({ signedTxData, depositAddress, apiKey, }) {
162
- const body = {
163
- depositAddr: depositAddress,
164
- signedTx: signedTxData,
165
- };
166
- const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'checkout/refuel', body, apiKey);
167
- if (!res) {
168
- // TODO: Better error handling
169
- throw new Error('Unable to perform refuelling');
170
- }
171
- return res;
172
- }
173
- exports.requestCheckoutRefuel = requestCheckoutRefuel;
174
- //# sourceMappingURL=CheckoutApis.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CheckoutApis.js","sourceRoot":"","sources":["../../../src/apis/CheckoutApis.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAwB;AACxB,+BAAyC;AAEzC,mDAA6C;AAC7C,sCAA4D;AAC5D,gDAAmE;AACnE,0DAI+B;AAkB/B;;;;;;;;;;GAUG;AACI,KAAK,UAAU,gBAAgB,CAAC,EACrC,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,8BAA8B,EAC9B,aAAa,EACb,WAAW,EACX,MAAM,GACkB;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,IAAA,2BAAW,EAAC;YACnC,OAAO,EAAE,SAAS;YAClB,YAAY,EAAE,cAAc;SAC7B,CAAC,CAAA;QACF,MAAM,WAAW,GAAG,EAAE,IAAI,UAAU,CAAA;QACpC,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,WAAW,CAAC,CAAC,CAAA;QAE1E,MAAM,WAAW,GAAG;YAClB,WAAW;YACX,gBAAgB;YAChB,SAAS;YACT,cAAc;YACd,gBAAgB,EAAE,kBAAkB,CAAC,QAAQ,EAAE;YAC/C,0CAA0C;YAC1C,GAAG,CAAC,IAAA,gBAAS,EAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,qGAAqG;YACrG,4IAA4I;YAC5I,mKAAmK;YACnK,kCAAkC,EAAE,IAAA,yCAAyB,EAC3D,IAAI,CAAC,KAAK,CAAC,CAAC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