@b3dotfun/sdk 0.0.7-alpha.25 → 0.0.7-alpha.27
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/cjs/anyspend/index.d.ts +0 -2
- package/dist/cjs/anyspend/index.js +0 -4
- package/dist/cjs/anyspend/react/components/AnySpend.js +49 -48
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +39 -38
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +0 -40
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +6 -6
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +7 -7
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +9 -8
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +14 -13
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampOrderStatus.js +0 -1
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +13 -12
- package/dist/cjs/anyspend/react/hooks/index.d.ts +0 -2
- package/dist/cjs/anyspend/react/hooks/index.js +0 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +0 -70
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +0 -70
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -39
- package/dist/cjs/anyspend/services/anyspend.js +0 -13
- package/dist/cjs/anyspend/types/index.d.ts +0 -1
- package/dist/cjs/anyspend/types/index.js +0 -1
- package/dist/cjs/anyspend/types/order.d.ts +0 -200
- package/dist/cjs/anyspend/types/order.js +1 -6
- package/dist/cjs/anyspend/types/req-res/createOrder.d.ts +0 -235
- package/dist/cjs/anyspend/types/req-res/getOrderAndTransactions.d.ts +0 -305
- package/dist/cjs/anyspend/types/req-res/getOrderHistory.d.ts +0 -235
- package/dist/cjs/anyspend/types/req-res/index.d.ts +0 -1
- package/dist/cjs/anyspend/types/req-res/index.js +0 -1
- package/dist/cjs/anyspend/utils/format.js +0 -4
- package/dist/cjs/global-account/react/components/custom/Button.d.ts +2 -2
- package/dist/cjs/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/cjs/shared/constants/chains/supported.d.ts +14 -14
- package/dist/cjs/shared/utils/insights.d.ts +1 -1
- package/dist/cjs/shared/utils/simplehash.d.ts +2 -2
- package/dist/esm/anyspend/index.d.ts +0 -2
- package/dist/esm/anyspend/index.js +0 -4
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +2 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +0 -40
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +2 -1
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -1
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampOrderStatus.js +0 -1
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -1
- package/dist/esm/anyspend/react/hooks/index.d.ts +0 -2
- package/dist/esm/anyspend/react/hooks/index.js +0 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +0 -70
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +0 -70
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -39
- package/dist/esm/anyspend/services/anyspend.js +0 -13
- package/dist/esm/anyspend/types/index.d.ts +0 -1
- package/dist/esm/anyspend/types/index.js +0 -1
- package/dist/esm/anyspend/types/order.d.ts +0 -200
- package/dist/esm/anyspend/types/order.js +1 -6
- package/dist/esm/anyspend/types/req-res/createOrder.d.ts +0 -235
- package/dist/esm/anyspend/types/req-res/getOrderAndTransactions.d.ts +0 -305
- package/dist/esm/anyspend/types/req-res/getOrderHistory.d.ts +0 -235
- package/dist/esm/anyspend/types/req-res/index.d.ts +0 -1
- package/dist/esm/anyspend/types/req-res/index.js +0 -1
- package/dist/esm/anyspend/utils/format.js +0 -4
- package/dist/esm/global-account/react/components/custom/Button.d.ts +2 -2
- package/dist/esm/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/esm/shared/constants/chains/supported.d.ts +14 -14
- package/dist/esm/shared/utils/insights.d.ts +1 -1
- package/dist/esm/shared/utils/simplehash.d.ts +2 -2
- package/dist/types/anyspend/index.d.ts +0 -2
- package/dist/types/anyspend/react/hooks/index.d.ts +0 -2
- package/dist/types/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +0 -70
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +0 -70
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/types/anyspend/services/anyspend.d.ts +1 -39
- package/dist/types/anyspend/types/index.d.ts +0 -1
- package/dist/types/anyspend/types/order.d.ts +0 -200
- package/dist/types/anyspend/types/req-res/createOrder.d.ts +0 -235
- package/dist/types/anyspend/types/req-res/getOrderAndTransactions.d.ts +0 -305
- package/dist/types/anyspend/types/req-res/getOrderHistory.d.ts +0 -235
- package/dist/types/anyspend/types/req-res/index.d.ts +0 -1
- package/dist/types/global-account/react/components/custom/Button.d.ts +2 -2
- package/dist/types/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/types/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/types/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/types/shared/constants/chains/supported.d.ts +14 -14
- package/dist/types/shared/utils/insights.d.ts +1 -1
- package/dist/types/shared/utils/simplehash.d.ts +2 -2
- package/package.json +1 -1
- package/src/anyspend/index.ts +0 -6
- package/src/anyspend/react/components/AnySpend.tsx +2 -6
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +0 -46
- package/src/anyspend/react/components/common/OrderHistory.tsx +1 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +1 -1
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +2 -10
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +2 -1
- package/src/anyspend/react/components/webview/WebviewOnrampOrderStatus.tsx +0 -1
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +1 -3
- package/src/anyspend/react/hooks/index.ts +0 -2
- package/src/anyspend/services/anyspend.ts +0 -18
- package/src/anyspend/types/index.ts +0 -1
- package/src/anyspend/types/order.ts +1 -8
- package/src/anyspend/types/req-res/index.ts +0 -1
- package/src/anyspend/utils/format.ts +0 -5
- package/dist/cjs/anyspend/react/hooks/useAnyspendSendPermitData.d.ts +0 -16
- package/dist/cjs/anyspend/react/hooks/useAnyspendSendPermitData.js +0 -39
- package/dist/cjs/anyspend/react/hooks/usePermitData.d.ts +0 -92
- package/dist/cjs/anyspend/react/hooks/usePermitData.js +0 -158
- package/dist/cjs/anyspend/types/permit.d.ts +0 -21
- package/dist/cjs/anyspend/types/permit.js +0 -11
- package/dist/cjs/anyspend/types/req-res/sendPermitData.d.ts +0 -66
- package/dist/cjs/anyspend/types/req-res/sendPermitData.js +0 -11
- package/dist/esm/anyspend/react/hooks/useAnyspendSendPermitData.d.ts +0 -16
- package/dist/esm/anyspend/react/hooks/useAnyspendSendPermitData.js +0 -36
- package/dist/esm/anyspend/react/hooks/usePermitData.d.ts +0 -92
- package/dist/esm/anyspend/react/hooks/usePermitData.js +0 -154
- package/dist/esm/anyspend/types/permit.d.ts +0 -21
- package/dist/esm/anyspend/types/permit.js +0 -8
- package/dist/esm/anyspend/types/req-res/sendPermitData.d.ts +0 -66
- package/dist/esm/anyspend/types/req-res/sendPermitData.js +0 -8
- package/dist/types/anyspend/react/hooks/useAnyspendSendPermitData.d.ts +0 -16
- package/dist/types/anyspend/react/hooks/usePermitData.d.ts +0 -92
- package/dist/types/anyspend/types/permit.d.ts +0 -21
- package/dist/types/anyspend/types/req-res/sendPermitData.d.ts +0 -66
- package/src/anyspend/react/hooks/useAnyspendSendPermitData.ts +0 -38
- package/src/anyspend/react/hooks/usePermitData.ts +0 -183
- package/src/anyspend/types/permit.ts +0 -10
- package/src/anyspend/types/req-res/sendPermitData.ts +0 -10
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { anyspendService } from "../../../anyspend/services/anyspend.js";
|
|
2
|
-
import { useMutation } from "@tanstack/react-query";
|
|
3
|
-
export function useAnyspendSendPermitData({ onSuccess, onError } = {}) {
|
|
4
|
-
const { mutate: sendPermitData, isPending } = useMutation({
|
|
5
|
-
mutationFn: async ({ isMainnet, orderId, permitData }) => {
|
|
6
|
-
try {
|
|
7
|
-
const response = await anyspendService.sendPermitData({
|
|
8
|
-
isMainnet,
|
|
9
|
-
orderId,
|
|
10
|
-
permitData,
|
|
11
|
-
});
|
|
12
|
-
if (response.statusCode !== 200)
|
|
13
|
-
throw response;
|
|
14
|
-
return response;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
// If the error has a response with message and statusCode, throw that
|
|
18
|
-
if (error.response?.data) {
|
|
19
|
-
throw error.response.data;
|
|
20
|
-
}
|
|
21
|
-
// Otherwise throw the original error
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
onSuccess: data => {
|
|
26
|
-
onSuccess?.(data);
|
|
27
|
-
},
|
|
28
|
-
onError: (error) => {
|
|
29
|
-
onError?.(error);
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
sendPermitData,
|
|
34
|
-
isSendingPermitData: isPending,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Address, Hex } from "viem";
|
|
2
|
-
export type GetPermitDataParams = {
|
|
3
|
-
chainId: number;
|
|
4
|
-
tokenAddress: Hex;
|
|
5
|
-
ownerAddress: Hex | undefined;
|
|
6
|
-
amount: bigint;
|
|
7
|
-
};
|
|
8
|
-
export declare function getPermitData(p: GetPermitDataParams): Promise<{
|
|
9
|
-
canPermit: boolean;
|
|
10
|
-
data: null;
|
|
11
|
-
} | {
|
|
12
|
-
canPermit: boolean;
|
|
13
|
-
data: {
|
|
14
|
-
domain: {
|
|
15
|
-
name: string;
|
|
16
|
-
version: string;
|
|
17
|
-
chainId: number;
|
|
18
|
-
verifyingContract: `0x${string}`;
|
|
19
|
-
};
|
|
20
|
-
types: {
|
|
21
|
-
Permit: {
|
|
22
|
-
name: string;
|
|
23
|
-
type: string;
|
|
24
|
-
}[];
|
|
25
|
-
};
|
|
26
|
-
messageToSign: {
|
|
27
|
-
owner: `0x${string}`;
|
|
28
|
-
spender: Address;
|
|
29
|
-
value: bigint;
|
|
30
|
-
nonce: bigint;
|
|
31
|
-
deadline: bigint;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
|
-
export declare function usePermitData(p: GetPermitDataParams): {
|
|
36
|
-
permitData: {
|
|
37
|
-
canPermit: boolean;
|
|
38
|
-
data: null;
|
|
39
|
-
} | {
|
|
40
|
-
canPermit: boolean;
|
|
41
|
-
data: {
|
|
42
|
-
domain: {
|
|
43
|
-
name: string;
|
|
44
|
-
version: string;
|
|
45
|
-
chainId: number;
|
|
46
|
-
verifyingContract: `0x${string}`;
|
|
47
|
-
};
|
|
48
|
-
types: {
|
|
49
|
-
Permit: {
|
|
50
|
-
name: string;
|
|
51
|
-
type: string;
|
|
52
|
-
}[];
|
|
53
|
-
};
|
|
54
|
-
messageToSign: {
|
|
55
|
-
owner: `0x${string}`;
|
|
56
|
-
spender: Address;
|
|
57
|
-
value: bigint;
|
|
58
|
-
nonce: bigint;
|
|
59
|
-
deadline: bigint;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
} | undefined;
|
|
63
|
-
isCheckingPermit: boolean;
|
|
64
|
-
checkPermitError: Error | null;
|
|
65
|
-
recheckPermit: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
66
|
-
canPermit: boolean;
|
|
67
|
-
data: null;
|
|
68
|
-
} | {
|
|
69
|
-
canPermit: boolean;
|
|
70
|
-
data: {
|
|
71
|
-
domain: {
|
|
72
|
-
name: string;
|
|
73
|
-
version: string;
|
|
74
|
-
chainId: number;
|
|
75
|
-
verifyingContract: `0x${string}`;
|
|
76
|
-
};
|
|
77
|
-
types: {
|
|
78
|
-
Permit: {
|
|
79
|
-
name: string;
|
|
80
|
-
type: string;
|
|
81
|
-
}[];
|
|
82
|
-
};
|
|
83
|
-
messageToSign: {
|
|
84
|
-
owner: `0x${string}`;
|
|
85
|
-
spender: Address;
|
|
86
|
-
value: bigint;
|
|
87
|
-
nonce: bigint;
|
|
88
|
-
deadline: bigint;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
}, Error>>;
|
|
92
|
-
};
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { chainIdToPublicClient, getMulticall3Address, isEvmChain, isNativeToken } from "../../../anyspend/utils/index.js";
|
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { ABI_USDC_BASE } from "../../../anyspend/abis/abi-usdc-base.js";
|
|
4
|
-
// EIP-5267 ABI for eip712Domain function
|
|
5
|
-
const EIP5267_ABI = [
|
|
6
|
-
{
|
|
7
|
-
inputs: [],
|
|
8
|
-
name: "eip712Domain",
|
|
9
|
-
outputs: [
|
|
10
|
-
{ name: "fields", type: "bytes1" },
|
|
11
|
-
{ name: "name", type: "string" },
|
|
12
|
-
{ name: "version", type: "string" },
|
|
13
|
-
{ name: "chainId", type: "uint256" },
|
|
14
|
-
{ name: "verifyingContract", type: "address" },
|
|
15
|
-
{ name: "salt", type: "bytes32" },
|
|
16
|
-
],
|
|
17
|
-
stateMutability: "view",
|
|
18
|
-
type: "function",
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
export async function getPermitData(p) {
|
|
22
|
-
console.log("Start getting permit data...");
|
|
23
|
-
if (!isEvmChain(p.chainId) || isNativeToken(p.tokenAddress) || !p.ownerAddress) {
|
|
24
|
-
return {
|
|
25
|
-
canPermit: false,
|
|
26
|
-
data: null,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const publicClient = chainIdToPublicClient(p.chainId);
|
|
30
|
-
const balance = await publicClient.readContract({
|
|
31
|
-
address: p.tokenAddress,
|
|
32
|
-
abi: ABI_USDC_BASE,
|
|
33
|
-
functionName: "balanceOf",
|
|
34
|
-
args: [p.ownerAddress],
|
|
35
|
-
});
|
|
36
|
-
if (balance < p.amount) {
|
|
37
|
-
return {
|
|
38
|
-
canPermit: false,
|
|
39
|
-
data: null,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
// Domain parameters
|
|
43
|
-
let name;
|
|
44
|
-
let version = "1"; // Default version for EIP-2612 (used by Uniswap V2 reference implementation)
|
|
45
|
-
// Try to get domain information using EIP-5267 (eip712Domain function)
|
|
46
|
-
try {
|
|
47
|
-
const domainData = await publicClient.readContract({
|
|
48
|
-
address: p.tokenAddress,
|
|
49
|
-
abi: EIP5267_ABI,
|
|
50
|
-
functionName: "eip712Domain",
|
|
51
|
-
});
|
|
52
|
-
console.log("Found EIP-5267 eip712Domain function");
|
|
53
|
-
name = domainData[1]; // name is the second return value
|
|
54
|
-
version = domainData[2]; // version is the third return value
|
|
55
|
-
console.log("Contract domain data from EIP-5267:");
|
|
56
|
-
console.log("- name:", name);
|
|
57
|
-
console.log("- version:", version);
|
|
58
|
-
console.log("- chainId:", domainData[3]);
|
|
59
|
-
console.log("- verifyingContract:", domainData[4]);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
console.log("[EIP-5267] eip712Domain function not found, falling back to individual calls");
|
|
63
|
-
// Fallback: get name from contract
|
|
64
|
-
name = await publicClient.readContract({
|
|
65
|
-
address: p.tokenAddress,
|
|
66
|
-
abi: ABI_USDC_BASE,
|
|
67
|
-
functionName: "name",
|
|
68
|
-
});
|
|
69
|
-
// Try to get version from contract
|
|
70
|
-
try {
|
|
71
|
-
version = await publicClient.readContract({
|
|
72
|
-
address: p.tokenAddress,
|
|
73
|
-
abi: ABI_USDC_BASE,
|
|
74
|
-
functionName: "version",
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
console.log(`Function "version" not found, using default version "1" (standard for EIP-2612)`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// Fetch the PERMIT_TYPEHASH - important for ensuring our structure matches the contract
|
|
82
|
-
const permitTypeHash = await publicClient
|
|
83
|
-
.readContract({
|
|
84
|
-
address: p.tokenAddress,
|
|
85
|
-
abi: ABI_USDC_BASE,
|
|
86
|
-
functionName: "PERMIT_TYPEHASH",
|
|
87
|
-
})
|
|
88
|
-
.catch(() => {
|
|
89
|
-
console.log("PERMIT_TYPEHASH not directly accessible, using standard EIP-2612 value");
|
|
90
|
-
return "0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9";
|
|
91
|
-
});
|
|
92
|
-
// Fetch the DOMAIN_SEPARATOR - critical for signature validation
|
|
93
|
-
const contractDomainSeparator = await publicClient.readContract({
|
|
94
|
-
address: p.tokenAddress,
|
|
95
|
-
abi: ABI_USDC_BASE,
|
|
96
|
-
functionName: "DOMAIN_SEPARATOR",
|
|
97
|
-
});
|
|
98
|
-
console.log("Contract name:", name);
|
|
99
|
-
console.log("Contract version:", version);
|
|
100
|
-
console.log("Contract PERMIT_TYPEHASH:", permitTypeHash);
|
|
101
|
-
console.log("Contract DOMAIN_SEPARATOR:", contractDomainSeparator);
|
|
102
|
-
// Domain data for EIP-712 signature
|
|
103
|
-
const domain = {
|
|
104
|
-
name,
|
|
105
|
-
version,
|
|
106
|
-
chainId: p.chainId,
|
|
107
|
-
verifyingContract: p.tokenAddress,
|
|
108
|
-
};
|
|
109
|
-
// EIP-2612 Permit type definition
|
|
110
|
-
// This must match the structure used to compute the PERMIT_TYPEHASH in the contract
|
|
111
|
-
const PermitType = [
|
|
112
|
-
{ name: "owner", type: "address" },
|
|
113
|
-
{ name: "spender", type: "address" },
|
|
114
|
-
{ name: "value", type: "uint256" },
|
|
115
|
-
{ name: "nonce", type: "uint256" },
|
|
116
|
-
{ name: "deadline", type: "uint256" },
|
|
117
|
-
];
|
|
118
|
-
const multicall3 = getMulticall3Address(p.chainId);
|
|
119
|
-
const nonce = await publicClient.readContract({
|
|
120
|
-
address: p.tokenAddress,
|
|
121
|
-
abi: ABI_USDC_BASE,
|
|
122
|
-
functionName: "nonces",
|
|
123
|
-
args: [p.ownerAddress],
|
|
124
|
-
});
|
|
125
|
-
const deadlineInSeconds = BigInt(Math.floor(Date.now() / 1000) + 60 * 60); // 60 minutes
|
|
126
|
-
// Permit data to sign
|
|
127
|
-
const messageToSign = {
|
|
128
|
-
owner: p.ownerAddress,
|
|
129
|
-
spender: multicall3,
|
|
130
|
-
value: p.amount,
|
|
131
|
-
nonce,
|
|
132
|
-
deadline: deadlineInSeconds,
|
|
133
|
-
};
|
|
134
|
-
return {
|
|
135
|
-
canPermit: true,
|
|
136
|
-
data: {
|
|
137
|
-
domain,
|
|
138
|
-
types: { Permit: PermitType },
|
|
139
|
-
messageToSign,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
export function usePermitData(p) {
|
|
144
|
-
const { data, isLoading, error, refetch } = useQuery({
|
|
145
|
-
queryKey: ["usePermitData", p.chainId, p.tokenAddress],
|
|
146
|
-
queryFn: () => getPermitData(p),
|
|
147
|
-
});
|
|
148
|
-
return {
|
|
149
|
-
permitData: data,
|
|
150
|
-
isCheckingPermit: isLoading,
|
|
151
|
-
checkPermitError: error,
|
|
152
|
-
recheckPermit: refetch,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const zPermit: z.ZodObject<{
|
|
3
|
-
ownerAddress: z.ZodString;
|
|
4
|
-
deadline: z.ZodNumber;
|
|
5
|
-
v: z.ZodNumber;
|
|
6
|
-
r: z.ZodString;
|
|
7
|
-
s: z.ZodString;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
ownerAddress: string;
|
|
10
|
-
deadline: number;
|
|
11
|
-
v: number;
|
|
12
|
-
r: string;
|
|
13
|
-
s: string;
|
|
14
|
-
}, {
|
|
15
|
-
ownerAddress: string;
|
|
16
|
-
deadline: number;
|
|
17
|
-
v: number;
|
|
18
|
-
r: string;
|
|
19
|
-
s: string;
|
|
20
|
-
}>;
|
|
21
|
-
export type Permit = z.infer<typeof zPermit>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const zSendPermitDataRequest: z.ZodObject<{
|
|
3
|
-
body: z.ZodObject<{
|
|
4
|
-
orderId: z.ZodString;
|
|
5
|
-
permitData: z.ZodObject<{
|
|
6
|
-
ownerAddress: z.ZodString;
|
|
7
|
-
deadline: z.ZodNumber;
|
|
8
|
-
v: z.ZodNumber;
|
|
9
|
-
r: z.ZodString;
|
|
10
|
-
s: z.ZodString;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
ownerAddress: string;
|
|
13
|
-
deadline: number;
|
|
14
|
-
v: number;
|
|
15
|
-
r: string;
|
|
16
|
-
s: string;
|
|
17
|
-
}, {
|
|
18
|
-
ownerAddress: string;
|
|
19
|
-
deadline: number;
|
|
20
|
-
v: number;
|
|
21
|
-
r: string;
|
|
22
|
-
s: string;
|
|
23
|
-
}>;
|
|
24
|
-
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
orderId: string;
|
|
26
|
-
permitData: {
|
|
27
|
-
ownerAddress: string;
|
|
28
|
-
deadline: number;
|
|
29
|
-
v: number;
|
|
30
|
-
r: string;
|
|
31
|
-
s: string;
|
|
32
|
-
};
|
|
33
|
-
}, {
|
|
34
|
-
orderId: string;
|
|
35
|
-
permitData: {
|
|
36
|
-
ownerAddress: string;
|
|
37
|
-
deadline: number;
|
|
38
|
-
v: number;
|
|
39
|
-
r: string;
|
|
40
|
-
s: string;
|
|
41
|
-
};
|
|
42
|
-
}>;
|
|
43
|
-
}, "strip", z.ZodTypeAny, {
|
|
44
|
-
body: {
|
|
45
|
-
orderId: string;
|
|
46
|
-
permitData: {
|
|
47
|
-
ownerAddress: string;
|
|
48
|
-
deadline: number;
|
|
49
|
-
v: number;
|
|
50
|
-
r: string;
|
|
51
|
-
s: string;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
}, {
|
|
55
|
-
body: {
|
|
56
|
-
orderId: string;
|
|
57
|
-
permitData: {
|
|
58
|
-
ownerAddress: string;
|
|
59
|
-
deadline: number;
|
|
60
|
-
v: number;
|
|
61
|
-
r: string;
|
|
62
|
-
s: string;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
}>;
|
|
66
|
-
export type SendPermitDataRequestBody = z.infer<typeof zSendPermitDataRequest.shape.body>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { UseAnyspendCreateOrderProps } from "./useAnyspendCreateOrder";
|
|
2
|
-
export declare function useAnyspendSendPermitData({ onSuccess, onError }?: UseAnyspendCreateOrderProps): {
|
|
3
|
-
sendPermitData: import("@tanstack/react-query").UseMutateFunction<any, Error, {
|
|
4
|
-
orderId: string;
|
|
5
|
-
permitData: {
|
|
6
|
-
ownerAddress: string;
|
|
7
|
-
deadline: number;
|
|
8
|
-
v: number;
|
|
9
|
-
r: string;
|
|
10
|
-
s: string;
|
|
11
|
-
};
|
|
12
|
-
} & {
|
|
13
|
-
isMainnet: boolean;
|
|
14
|
-
}, unknown>;
|
|
15
|
-
isSendingPermitData: boolean;
|
|
16
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Address, Hex } from "viem";
|
|
2
|
-
export type GetPermitDataParams = {
|
|
3
|
-
chainId: number;
|
|
4
|
-
tokenAddress: Hex;
|
|
5
|
-
ownerAddress: Hex | undefined;
|
|
6
|
-
amount: bigint;
|
|
7
|
-
};
|
|
8
|
-
export declare function getPermitData(p: GetPermitDataParams): Promise<{
|
|
9
|
-
canPermit: boolean;
|
|
10
|
-
data: null;
|
|
11
|
-
} | {
|
|
12
|
-
canPermit: boolean;
|
|
13
|
-
data: {
|
|
14
|
-
domain: {
|
|
15
|
-
name: string;
|
|
16
|
-
version: string;
|
|
17
|
-
chainId: number;
|
|
18
|
-
verifyingContract: `0x${string}`;
|
|
19
|
-
};
|
|
20
|
-
types: {
|
|
21
|
-
Permit: {
|
|
22
|
-
name: string;
|
|
23
|
-
type: string;
|
|
24
|
-
}[];
|
|
25
|
-
};
|
|
26
|
-
messageToSign: {
|
|
27
|
-
owner: `0x${string}`;
|
|
28
|
-
spender: Address;
|
|
29
|
-
value: bigint;
|
|
30
|
-
nonce: bigint;
|
|
31
|
-
deadline: bigint;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
|
-
export declare function usePermitData(p: GetPermitDataParams): {
|
|
36
|
-
permitData: {
|
|
37
|
-
canPermit: boolean;
|
|
38
|
-
data: null;
|
|
39
|
-
} | {
|
|
40
|
-
canPermit: boolean;
|
|
41
|
-
data: {
|
|
42
|
-
domain: {
|
|
43
|
-
name: string;
|
|
44
|
-
version: string;
|
|
45
|
-
chainId: number;
|
|
46
|
-
verifyingContract: `0x${string}`;
|
|
47
|
-
};
|
|
48
|
-
types: {
|
|
49
|
-
Permit: {
|
|
50
|
-
name: string;
|
|
51
|
-
type: string;
|
|
52
|
-
}[];
|
|
53
|
-
};
|
|
54
|
-
messageToSign: {
|
|
55
|
-
owner: `0x${string}`;
|
|
56
|
-
spender: Address;
|
|
57
|
-
value: bigint;
|
|
58
|
-
nonce: bigint;
|
|
59
|
-
deadline: bigint;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
} | undefined;
|
|
63
|
-
isCheckingPermit: boolean;
|
|
64
|
-
checkPermitError: Error | null;
|
|
65
|
-
recheckPermit: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
66
|
-
canPermit: boolean;
|
|
67
|
-
data: null;
|
|
68
|
-
} | {
|
|
69
|
-
canPermit: boolean;
|
|
70
|
-
data: {
|
|
71
|
-
domain: {
|
|
72
|
-
name: string;
|
|
73
|
-
version: string;
|
|
74
|
-
chainId: number;
|
|
75
|
-
verifyingContract: `0x${string}`;
|
|
76
|
-
};
|
|
77
|
-
types: {
|
|
78
|
-
Permit: {
|
|
79
|
-
name: string;
|
|
80
|
-
type: string;
|
|
81
|
-
}[];
|
|
82
|
-
};
|
|
83
|
-
messageToSign: {
|
|
84
|
-
owner: `0x${string}`;
|
|
85
|
-
spender: Address;
|
|
86
|
-
value: bigint;
|
|
87
|
-
nonce: bigint;
|
|
88
|
-
deadline: bigint;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
}, Error>>;
|
|
92
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const zPermit: z.ZodObject<{
|
|
3
|
-
ownerAddress: z.ZodString;
|
|
4
|
-
deadline: z.ZodNumber;
|
|
5
|
-
v: z.ZodNumber;
|
|
6
|
-
r: z.ZodString;
|
|
7
|
-
s: z.ZodString;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
ownerAddress: string;
|
|
10
|
-
deadline: number;
|
|
11
|
-
v: number;
|
|
12
|
-
r: string;
|
|
13
|
-
s: string;
|
|
14
|
-
}, {
|
|
15
|
-
ownerAddress: string;
|
|
16
|
-
deadline: number;
|
|
17
|
-
v: number;
|
|
18
|
-
r: string;
|
|
19
|
-
s: string;
|
|
20
|
-
}>;
|
|
21
|
-
export type Permit = z.infer<typeof zPermit>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const zSendPermitDataRequest: z.ZodObject<{
|
|
3
|
-
body: z.ZodObject<{
|
|
4
|
-
orderId: z.ZodString;
|
|
5
|
-
permitData: z.ZodObject<{
|
|
6
|
-
ownerAddress: z.ZodString;
|
|
7
|
-
deadline: z.ZodNumber;
|
|
8
|
-
v: z.ZodNumber;
|
|
9
|
-
r: z.ZodString;
|
|
10
|
-
s: z.ZodString;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
ownerAddress: string;
|
|
13
|
-
deadline: number;
|
|
14
|
-
v: number;
|
|
15
|
-
r: string;
|
|
16
|
-
s: string;
|
|
17
|
-
}, {
|
|
18
|
-
ownerAddress: string;
|
|
19
|
-
deadline: number;
|
|
20
|
-
v: number;
|
|
21
|
-
r: string;
|
|
22
|
-
s: string;
|
|
23
|
-
}>;
|
|
24
|
-
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
orderId: string;
|
|
26
|
-
permitData: {
|
|
27
|
-
ownerAddress: string;
|
|
28
|
-
deadline: number;
|
|
29
|
-
v: number;
|
|
30
|
-
r: string;
|
|
31
|
-
s: string;
|
|
32
|
-
};
|
|
33
|
-
}, {
|
|
34
|
-
orderId: string;
|
|
35
|
-
permitData: {
|
|
36
|
-
ownerAddress: string;
|
|
37
|
-
deadline: number;
|
|
38
|
-
v: number;
|
|
39
|
-
r: string;
|
|
40
|
-
s: string;
|
|
41
|
-
};
|
|
42
|
-
}>;
|
|
43
|
-
}, "strip", z.ZodTypeAny, {
|
|
44
|
-
body: {
|
|
45
|
-
orderId: string;
|
|
46
|
-
permitData: {
|
|
47
|
-
ownerAddress: string;
|
|
48
|
-
deadline: number;
|
|
49
|
-
v: number;
|
|
50
|
-
r: string;
|
|
51
|
-
s: string;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
}, {
|
|
55
|
-
body: {
|
|
56
|
-
orderId: string;
|
|
57
|
-
permitData: {
|
|
58
|
-
ownerAddress: string;
|
|
59
|
-
deadline: number;
|
|
60
|
-
v: number;
|
|
61
|
-
r: string;
|
|
62
|
-
s: string;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
}>;
|
|
66
|
-
export type SendPermitDataRequestBody = z.infer<typeof zSendPermitDataRequest.shape.body>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
2
|
-
import { SendPermitDataRequestBody } from "@b3dotfun/sdk/anyspend/types";
|
|
3
|
-
import { useMutation } from "@tanstack/react-query";
|
|
4
|
-
import { UseAnyspendCreateOrderProps } from "./useAnyspendCreateOrder";
|
|
5
|
-
|
|
6
|
-
export function useAnyspendSendPermitData({ onSuccess, onError }: UseAnyspendCreateOrderProps = {}) {
|
|
7
|
-
const { mutate: sendPermitData, isPending } = useMutation({
|
|
8
|
-
mutationFn: async ({ isMainnet, orderId, permitData }: SendPermitDataRequestBody & { isMainnet: boolean }) => {
|
|
9
|
-
try {
|
|
10
|
-
const response = await anyspendService.sendPermitData({
|
|
11
|
-
isMainnet,
|
|
12
|
-
orderId,
|
|
13
|
-
permitData,
|
|
14
|
-
});
|
|
15
|
-
if (response.statusCode !== 200) throw response;
|
|
16
|
-
return response;
|
|
17
|
-
} catch (error: any) {
|
|
18
|
-
// If the error has a response with message and statusCode, throw that
|
|
19
|
-
if (error.response?.data) {
|
|
20
|
-
throw error.response.data;
|
|
21
|
-
}
|
|
22
|
-
// Otherwise throw the original error
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
onSuccess: data => {
|
|
27
|
-
onSuccess?.(data);
|
|
28
|
-
},
|
|
29
|
-
onError: (error: Error) => {
|
|
30
|
-
onError?.(error);
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
sendPermitData,
|
|
36
|
-
isSendingPermitData: isPending,
|
|
37
|
-
};
|
|
38
|
-
}
|