@voyage_ai/v402-web-ts 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +139 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -80
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +50 -1
- package/dist/react/index.d.ts +50 -1
- package/dist/react/index.js +1559 -136
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +1541 -112
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/styles.css +1 -168
- package/package.json +33 -10
- package/dist/react/components/WalletConnect.tsx +0 -152
- package/dist/react/hooks/usePayment.ts +0 -109
- package/dist/react/hooks/usePaymentInfo.ts +0 -128
- package/dist/react/hooks/useWallet.ts +0 -174
- package/dist/react/hooks/useWalletStore.ts +0 -61
- package/dist/react/index.ts +0 -38
- package/dist/react/store/walletStore.ts +0 -181
- package/dist/react/styles/inline-styles.ts +0 -238
package/dist/index.mjs
CHANGED
|
@@ -1,80 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
VerifyResponseSchema,
|
|
6
|
-
SettleResponseSchema,
|
|
7
|
-
SupportedPaymentKindSchema,
|
|
8
|
-
SupportedPaymentKindsResponseSchema,
|
|
9
|
-
ExactSvmPayloadSchema as ExactSvmPayloadSchema2,
|
|
10
|
-
ExactEvmPayloadSchema as ExactEvmPayloadSchema2,
|
|
11
|
-
SupportedSVMNetworks,
|
|
12
|
-
SvmNetworkToChainId
|
|
13
|
-
} from "x402/types";
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __esm = (fn, res) => function __init() {
|
|
3
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
|
+
};
|
|
14
5
|
|
|
15
6
|
// src/types/common.ts
|
|
16
|
-
var PROD_BACK_URL
|
|
7
|
+
var PROD_BACK_URL;
|
|
8
|
+
var init_common = __esm({
|
|
9
|
+
"src/types/common.ts"() {
|
|
10
|
+
"use strict";
|
|
11
|
+
PROD_BACK_URL = "https://v402.onvoyage.ai/api/pay";
|
|
12
|
+
}
|
|
13
|
+
});
|
|
17
14
|
|
|
18
15
|
// src/types/svm.ts
|
|
19
16
|
import { z } from "zod";
|
|
20
17
|
import { ExactSvmPayloadSchema } from "x402/types";
|
|
21
|
-
var SolanaNetworkSchema
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
var SolanaNetworkSchema, SolanaPaymentPayloadSchema;
|
|
19
|
+
var init_svm = __esm({
|
|
20
|
+
"src/types/svm.ts"() {
|
|
21
|
+
"use strict";
|
|
22
|
+
SolanaNetworkSchema = z.enum([
|
|
23
|
+
"solana-devnet",
|
|
24
|
+
"solana",
|
|
25
|
+
"solana-mainnet"
|
|
26
|
+
// Alias for mainnet
|
|
27
|
+
]);
|
|
28
|
+
SolanaPaymentPayloadSchema = z.object({
|
|
29
|
+
x402Version: z.literal(1),
|
|
30
|
+
scheme: z.literal("exact"),
|
|
31
|
+
network: SolanaNetworkSchema,
|
|
32
|
+
payload: ExactSvmPayloadSchema
|
|
33
|
+
});
|
|
34
|
+
}
|
|
32
35
|
});
|
|
33
36
|
|
|
34
37
|
// src/types/evm.ts
|
|
35
38
|
import { z as z2 } from "zod";
|
|
36
39
|
import { ExactEvmPayloadSchema } from "x402/types";
|
|
37
|
-
var EvmNetworkSchema = z2.enum([
|
|
38
|
-
"ethereum",
|
|
39
|
-
"sepolia",
|
|
40
|
-
"base",
|
|
41
|
-
"base-sepolia",
|
|
42
|
-
"polygon",
|
|
43
|
-
"arbitrum",
|
|
44
|
-
"optimism"
|
|
45
|
-
]);
|
|
46
|
-
var EvmPaymentPayloadSchema = z2.object({
|
|
47
|
-
x402Version: z2.literal(1),
|
|
48
|
-
scheme: z2.literal("exact"),
|
|
49
|
-
network: EvmNetworkSchema,
|
|
50
|
-
payload: ExactEvmPayloadSchema
|
|
51
|
-
});
|
|
52
|
-
var EVM_NETWORK_CONFIGS = {
|
|
53
|
-
"ethereum": {
|
|
54
|
-
chainId: "0x1",
|
|
55
|
-
chainName: "Ethereum Mainnet",
|
|
56
|
-
rpcUrls: ["https://eth.llamarpc.com"],
|
|
57
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
|
|
58
|
-
},
|
|
59
|
-
"sepolia": {
|
|
60
|
-
chainId: "0xaa36a7",
|
|
61
|
-
chainName: "Sepolia",
|
|
62
|
-
rpcUrls: ["https://sepolia.infura.io/v3/"],
|
|
63
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
|
|
64
|
-
},
|
|
65
|
-
"base": {
|
|
66
|
-
chainId: "0x2105",
|
|
67
|
-
chainName: "Base",
|
|
68
|
-
rpcUrls: ["https://mainnet.base.org"],
|
|
69
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
|
|
70
|
-
},
|
|
71
|
-
"base-sepolia": {
|
|
72
|
-
chainId: "0x14a34",
|
|
73
|
-
chainName: "Base Sepolia",
|
|
74
|
-
rpcUrls: ["https://sepolia.base.org"],
|
|
75
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
40
|
function getChainId(network) {
|
|
79
41
|
const chainIdMap = {
|
|
80
42
|
"ethereum": 1,
|
|
@@ -87,22 +49,72 @@ function getChainId(network) {
|
|
|
87
49
|
};
|
|
88
50
|
return chainIdMap[network.toLowerCase()] || 1;
|
|
89
51
|
}
|
|
52
|
+
var EvmNetworkSchema, EvmPaymentPayloadSchema, EVM_NETWORK_CONFIGS;
|
|
53
|
+
var init_evm = __esm({
|
|
54
|
+
"src/types/evm.ts"() {
|
|
55
|
+
"use strict";
|
|
56
|
+
EvmNetworkSchema = z2.enum([
|
|
57
|
+
"ethereum",
|
|
58
|
+
"sepolia",
|
|
59
|
+
"base",
|
|
60
|
+
"base-sepolia",
|
|
61
|
+
"polygon",
|
|
62
|
+
"arbitrum",
|
|
63
|
+
"optimism"
|
|
64
|
+
]);
|
|
65
|
+
EvmPaymentPayloadSchema = z2.object({
|
|
66
|
+
x402Version: z2.literal(1),
|
|
67
|
+
scheme: z2.literal("exact"),
|
|
68
|
+
network: EvmNetworkSchema,
|
|
69
|
+
payload: ExactEvmPayloadSchema
|
|
70
|
+
});
|
|
71
|
+
EVM_NETWORK_CONFIGS = {
|
|
72
|
+
"ethereum": {
|
|
73
|
+
chainId: "0x1",
|
|
74
|
+
chainName: "Ethereum Mainnet",
|
|
75
|
+
rpcUrls: ["https://eth.llamarpc.com"],
|
|
76
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
|
|
77
|
+
},
|
|
78
|
+
"sepolia": {
|
|
79
|
+
chainId: "0xaa36a7",
|
|
80
|
+
chainName: "Sepolia",
|
|
81
|
+
rpcUrls: ["https://sepolia.infura.io/v3/"],
|
|
82
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
|
|
83
|
+
},
|
|
84
|
+
"base": {
|
|
85
|
+
chainId: "0x2105",
|
|
86
|
+
chainName: "Base",
|
|
87
|
+
rpcUrls: ["https://mainnet.base.org"],
|
|
88
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
|
|
89
|
+
},
|
|
90
|
+
"base-sepolia": {
|
|
91
|
+
chainId: "0x14a34",
|
|
92
|
+
chainName: "Base Sepolia",
|
|
93
|
+
rpcUrls: ["https://sepolia.base.org"],
|
|
94
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
});
|
|
90
99
|
|
|
91
|
-
// src/
|
|
92
|
-
import {
|
|
93
|
-
ComputeBudgetProgram,
|
|
94
|
-
Connection,
|
|
95
|
-
PublicKey,
|
|
96
|
-
TransactionMessage,
|
|
97
|
-
VersionedTransaction
|
|
98
|
-
} from "@solana/web3.js";
|
|
100
|
+
// src/types/index.ts
|
|
99
101
|
import {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
PaymentRequirementsSchema,
|
|
103
|
+
x402ResponseSchema,
|
|
104
|
+
VerifyResponseSchema,
|
|
105
|
+
SettleResponseSchema,
|
|
106
|
+
SupportedPaymentKindSchema,
|
|
107
|
+
SupportedPaymentKindsResponseSchema,
|
|
108
|
+
SupportedSVMNetworks,
|
|
109
|
+
SvmNetworkToChainId
|
|
110
|
+
} from "x402/types";
|
|
111
|
+
var init_types = __esm({
|
|
112
|
+
"src/types/index.ts"() {
|
|
113
|
+
"use strict";
|
|
114
|
+
init_svm();
|
|
115
|
+
init_evm();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
106
118
|
|
|
107
119
|
// src/utils/wallet.ts
|
|
108
120
|
function isWalletInstalled(networkType) {
|
|
@@ -161,6 +173,33 @@ function getWalletDisplayName(networkType) {
|
|
|
161
173
|
return "Unknown Wallet";
|
|
162
174
|
}
|
|
163
175
|
}
|
|
176
|
+
var init_wallet = __esm({
|
|
177
|
+
"src/utils/wallet.ts"() {
|
|
178
|
+
"use strict";
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// src/index.ts
|
|
183
|
+
init_types();
|
|
184
|
+
|
|
185
|
+
// src/services/svm/payment-header.ts
|
|
186
|
+
import {
|
|
187
|
+
ComputeBudgetProgram,
|
|
188
|
+
Connection,
|
|
189
|
+
PublicKey,
|
|
190
|
+
TransactionMessage,
|
|
191
|
+
VersionedTransaction
|
|
192
|
+
} from "@solana/web3.js";
|
|
193
|
+
import {
|
|
194
|
+
createTransferCheckedInstruction,
|
|
195
|
+
getAssociatedTokenAddress,
|
|
196
|
+
getMint,
|
|
197
|
+
TOKEN_2022_PROGRAM_ID,
|
|
198
|
+
TOKEN_PROGRAM_ID
|
|
199
|
+
} from "@solana/spl-token";
|
|
200
|
+
|
|
201
|
+
// src/utils/index.ts
|
|
202
|
+
init_wallet();
|
|
164
203
|
|
|
165
204
|
// src/services/evm/payment-header.ts
|
|
166
205
|
import { ethers } from "ethers";
|
|
@@ -276,6 +315,7 @@ function getChainIdFromNetwork(network) {
|
|
|
276
315
|
}
|
|
277
316
|
|
|
278
317
|
// src/services/evm/payment-handler.ts
|
|
318
|
+
init_types();
|
|
279
319
|
async function handleEvmPayment(endpoint, config, requestInit) {
|
|
280
320
|
const { wallet, network, maxPaymentAmount } = config;
|
|
281
321
|
const initialResponse = await fetch(endpoint, {
|
|
@@ -451,6 +491,7 @@ function createEvmPaymentFetch(config) {
|
|
|
451
491
|
}
|
|
452
492
|
|
|
453
493
|
// src/utils/payment-helpers.ts
|
|
494
|
+
init_common();
|
|
454
495
|
import { ethers as ethers2 } from "ethers";
|
|
455
496
|
async function makePayment(networkType, merchantId, endpoint = PROD_BACK_URL, additionalParams) {
|
|
456
497
|
const fullEndpoint = `${endpoint}/${merchantId}`;
|
|
@@ -826,6 +867,7 @@ function getDefaultSolanaRpcUrl(network) {
|
|
|
826
867
|
}
|
|
827
868
|
|
|
828
869
|
// src/services/svm/payment-handler.ts
|
|
870
|
+
init_types();
|
|
829
871
|
async function handleSvmPayment(endpoint, config, requestInit) {
|
|
830
872
|
const { wallet, network, rpcUrl, maxPaymentAmount } = config;
|
|
831
873
|
const initialResponse = await fetch(endpoint, {
|