@dexterai/x402 3.0.1 → 3.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.
@@ -1,111 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/utils/index.ts
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- fromAtomicUnits: () => fromAtomicUnits,
24
- getChainFamily: () => getChainFamily,
25
- getChainName: () => getChainName,
26
- getExplorerUrl: () => getExplorerUrl,
27
- toAtomicUnits: () => toAtomicUnits
28
- });
29
- module.exports = __toCommonJS(utils_exports);
30
-
31
- // src/types.ts
32
- var SOLANA_MAINNET_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
33
- var BASE_MAINNET_NETWORK = "eip155:8453";
34
-
35
- // src/utils.ts
36
- function toAtomicUnits(amount, decimals) {
37
- const multiplier = Math.pow(10, decimals);
38
- return Math.floor(amount * multiplier).toString();
39
- }
40
- function fromAtomicUnits(atomicUnits, decimals) {
41
- const divisor = Math.pow(10, decimals);
42
- return Number(atomicUnits) / divisor;
43
- }
44
- function isSolanaNetwork(network) {
45
- return network.startsWith("solana:") || network === "solana";
46
- }
47
- function isEvmNetwork(network) {
48
- return network.startsWith("eip155:") || ["base", "ethereum", "arbitrum"].includes(network);
49
- }
50
- function getChainFamily(network) {
51
- if (isSolanaNetwork(network)) return "solana";
52
- if (isEvmNetwork(network)) return "evm";
53
- return "unknown";
54
- }
55
- function getChainName(network) {
56
- const mapping = {
57
- [SOLANA_MAINNET_NETWORK]: "Solana",
58
- "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": "Solana Devnet",
59
- "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z": "Solana Testnet",
60
- "solana": "Solana",
61
- [BASE_MAINNET_NETWORK]: "Base",
62
- "eip155:84532": "Base Sepolia",
63
- "eip155:1": "Ethereum",
64
- "eip155:42161": "Arbitrum One",
65
- "base": "Base",
66
- "ethereum": "Ethereum",
67
- "arbitrum": "Arbitrum"
68
- };
69
- return mapping[network] || network;
70
- }
71
- function getExplorerUrl(txSignature, network) {
72
- const family = getChainFamily(network);
73
- if (family === "solana") {
74
- const isDevnet = network.includes("devnet") || network === "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
75
- if (isDevnet) {
76
- return `https://solscan.io/tx/${txSignature}?cluster=devnet`;
77
- }
78
- return `https://www.orbmarkets.io/tx/${txSignature}`;
79
- }
80
- if (family === "evm") {
81
- let chainId = "8453";
82
- if (network.startsWith("eip155:")) {
83
- chainId = network.split(":")[1];
84
- } else if (network === "ethereum") {
85
- chainId = "1";
86
- } else if (network === "arbitrum") {
87
- chainId = "42161";
88
- }
89
- switch (chainId) {
90
- case "8453":
91
- return `https://basescan.org/tx/${txSignature}`;
92
- case "84532":
93
- return `https://sepolia.basescan.org/tx/${txSignature}`;
94
- case "1":
95
- return `https://etherscan.io/tx/${txSignature}`;
96
- case "42161":
97
- return `https://arbiscan.io/tx/${txSignature}`;
98
- default:
99
- return `https://basescan.org/tx/${txSignature}`;
100
- }
101
- }
102
- return `https://solscan.io/tx/${txSignature}`;
103
- }
104
- // Annotate the CommonJS export names for ESM import in node:
105
- 0 && (module.exports = {
106
- fromAtomicUnits,
107
- getChainFamily,
108
- getChainName,
109
- getExplorerUrl,
110
- toAtomicUnits
111
- });
1
+ "use strict";var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},h=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of d(t))!g.call(e,s)&&s!==r&&i(e,s,{get:()=>t[s],enumerable:!(n=m(t,s))||n.enumerable});return e};var _=e=>h(i({},"__esModule",{value:!0}),e);var A={};x(A,{fromAtomicUnits:()=>u,getChainFamily:()=>a,getChainName:()=>l,getExplorerUrl:()=>f,toAtomicUnits:()=>p});module.exports=_(A);var o="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",c="eip155:8453";function p(e,t){let r=Math.pow(10,t);return Math.floor(e*r).toString()}function u(e,t){let r=Math.pow(10,t);return Number(e)/r}function b(e){return e.startsWith("solana:")||e==="solana"}function y(e){return e.startsWith("eip155:")||["base","ethereum","arbitrum"].includes(e)}function a(e){return b(e)?"solana":y(e)?"evm":"unknown"}function l(e){return{[o]:"Solana","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1":"Solana Devnet","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"Solana Testnet",solana:"Solana",[c]:"Base","eip155:84532":"Base Sepolia","eip155:1":"Ethereum","eip155:42161":"Arbitrum One",base:"Base",ethereum:"Ethereum",arbitrum:"Arbitrum"}[e]||e}function f(e,t){let r=a(t);if(r==="solana")return t.includes("devnet")||t==="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"?`https://solscan.io/tx/${e}?cluster=devnet`:`https://www.orbmarkets.io/tx/${e}`;if(r==="evm"){let n="8453";switch(t.startsWith("eip155:")?n=t.split(":")[1]:t==="ethereum"?n="1":t==="arbitrum"&&(n="42161"),n){case"8453":return`https://basescan.org/tx/${e}`;case"84532":return`https://sepolia.basescan.org/tx/${e}`;case"1":return`https://etherscan.io/tx/${e}`;case"42161":return`https://arbiscan.io/tx/${e}`;default:return`https://basescan.org/tx/${e}`}}return`https://solscan.io/tx/${e}`}0&&(module.exports={fromAtomicUnits,getChainFamily,getChainName,getExplorerUrl,toAtomicUnits});
@@ -1,80 +1 @@
1
- // src/types.ts
2
- var SOLANA_MAINNET_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
3
- var BASE_MAINNET_NETWORK = "eip155:8453";
4
-
5
- // src/utils.ts
6
- function toAtomicUnits(amount, decimals) {
7
- const multiplier = Math.pow(10, decimals);
8
- return Math.floor(amount * multiplier).toString();
9
- }
10
- function fromAtomicUnits(atomicUnits, decimals) {
11
- const divisor = Math.pow(10, decimals);
12
- return Number(atomicUnits) / divisor;
13
- }
14
- function isSolanaNetwork(network) {
15
- return network.startsWith("solana:") || network === "solana";
16
- }
17
- function isEvmNetwork(network) {
18
- return network.startsWith("eip155:") || ["base", "ethereum", "arbitrum"].includes(network);
19
- }
20
- function getChainFamily(network) {
21
- if (isSolanaNetwork(network)) return "solana";
22
- if (isEvmNetwork(network)) return "evm";
23
- return "unknown";
24
- }
25
- function getChainName(network) {
26
- const mapping = {
27
- [SOLANA_MAINNET_NETWORK]: "Solana",
28
- "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": "Solana Devnet",
29
- "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z": "Solana Testnet",
30
- "solana": "Solana",
31
- [BASE_MAINNET_NETWORK]: "Base",
32
- "eip155:84532": "Base Sepolia",
33
- "eip155:1": "Ethereum",
34
- "eip155:42161": "Arbitrum One",
35
- "base": "Base",
36
- "ethereum": "Ethereum",
37
- "arbitrum": "Arbitrum"
38
- };
39
- return mapping[network] || network;
40
- }
41
- function getExplorerUrl(txSignature, network) {
42
- const family = getChainFamily(network);
43
- if (family === "solana") {
44
- const isDevnet = network.includes("devnet") || network === "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
45
- if (isDevnet) {
46
- return `https://solscan.io/tx/${txSignature}?cluster=devnet`;
47
- }
48
- return `https://www.orbmarkets.io/tx/${txSignature}`;
49
- }
50
- if (family === "evm") {
51
- let chainId = "8453";
52
- if (network.startsWith("eip155:")) {
53
- chainId = network.split(":")[1];
54
- } else if (network === "ethereum") {
55
- chainId = "1";
56
- } else if (network === "arbitrum") {
57
- chainId = "42161";
58
- }
59
- switch (chainId) {
60
- case "8453":
61
- return `https://basescan.org/tx/${txSignature}`;
62
- case "84532":
63
- return `https://sepolia.basescan.org/tx/${txSignature}`;
64
- case "1":
65
- return `https://etherscan.io/tx/${txSignature}`;
66
- case "42161":
67
- return `https://arbiscan.io/tx/${txSignature}`;
68
- default:
69
- return `https://basescan.org/tx/${txSignature}`;
70
- }
71
- }
72
- return `https://solscan.io/tx/${txSignature}`;
73
- }
74
- export {
75
- fromAtomicUnits,
76
- getChainFamily,
77
- getChainName,
78
- getExplorerUrl,
79
- toAtomicUnits
80
- };
1
+ var s="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",i="eip155:8453";function o(e,t){let r=Math.pow(10,t);return Math.floor(e*r).toString()}function c(e,t){let r=Math.pow(10,t);return Number(e)/r}function p(e){return e.startsWith("solana:")||e==="solana"}function u(e){return e.startsWith("eip155:")||["base","ethereum","arbitrum"].includes(e)}function a(e){return p(e)?"solana":u(e)?"evm":"unknown"}function l(e){return{[s]:"Solana","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1":"Solana Devnet","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"Solana Testnet",solana:"Solana",[i]:"Base","eip155:84532":"Base Sepolia","eip155:1":"Ethereum","eip155:42161":"Arbitrum One",base:"Base",ethereum:"Ethereum",arbitrum:"Arbitrum"}[e]||e}function f(e,t){let r=a(t);if(r==="solana")return t.includes("devnet")||t==="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"?`https://solscan.io/tx/${e}?cluster=devnet`:`https://www.orbmarkets.io/tx/${e}`;if(r==="evm"){let n="8453";switch(t.startsWith("eip155:")?n=t.split(":")[1]:t==="ethereum"?n="1":t==="arbitrum"&&(n="42161"),n){case"8453":return`https://basescan.org/tx/${e}`;case"84532":return`https://sepolia.basescan.org/tx/${e}`;case"1":return`https://etherscan.io/tx/${e}`;case"42161":return`https://arbiscan.io/tx/${e}`;default:return`https://basescan.org/tx/${e}`}}return`https://solscan.io/tx/${e}`}export{c as fromAtomicUnits,a as getChainFamily,l as getChainName,f as getExplorerUrl,o as toAtomicUnits};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexterai/x402",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "Full-stack x402 SDK - add paid API monetization to any endpoint. Express middleware, React hooks, Access Pass, dynamic pricing. Solana, Base, Polygon, Arbitrum, Optimism, Avalanche, SKALE.",
5
5
  "author": "Dexter",
6
6
  "license": "MIT",
@@ -51,8 +51,8 @@
51
51
  "release:major": "npm version major && npm publish --access public"
52
52
  },
53
53
  "dependencies": {
54
- "@dexterai/x402-ads-types": "^0.1.0",
55
- "@dexterai/x402-core": "^1.0.0",
54
+ "@dexterai/x402-ads-types": "^0.2.0",
55
+ "@dexterai/x402-core": "^1.1.0",
56
56
  "@solana/spl-token": "^0.4.9",
57
57
  "@solana/web3.js": "^1.98.0"
58
58
  },