@zoralabs/coins-sdk 0.2.8 → 0.2.10

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.
@@ -101,15 +101,23 @@ export async function tradeCoin({
101
101
  }: {
102
102
  tradeParameters: TradeParameters;
103
103
  walletClient: WalletClient;
104
- account: Account;
104
+ account?: Account | Address;
105
105
  publicClient: GenericPublicClient;
106
106
  validateTransaction?: boolean;
107
107
  }) {
108
108
  const quote = await createTradeCall(tradeParameters);
109
109
 
110
+ if (!account) {
111
+ account = walletClient.account;
112
+ }
113
+ if (!account) {
114
+ throw new Error("Account is required");
115
+ }
116
+
110
117
  // Set default recipient to wallet sender address if not provided
111
118
  if (!tradeParameters.recipient) {
112
- tradeParameters.recipient = account.address;
119
+ tradeParameters.recipient =
120
+ typeof account === "string" ? account : account.address;
113
121
  }
114
122
 
115
123
  // todo replace any
@@ -123,7 +131,7 @@ export async function tradeCoin({
123
131
  functionName: "allowance",
124
132
  args: [
125
133
  permit.permit.details.token as Address,
126
- account.address,
134
+ typeof account === "string" ? account : account.address,
127
135
  permit.permit.spender as Address,
128
136
  ],
129
137
  });
@@ -132,7 +140,10 @@ export async function tradeCoin({
132
140
  abi: erc20Abi,
133
141
  address: permitToken,
134
142
  functionName: "allowance",
135
- args: [account.address, permit2Address[base.id]],
143
+ args: [
144
+ typeof account === "string" ? account : account.address,
145
+ permit2Address[base.id],
146
+ ],
136
147
  });
137
148
  if (allowance < BigInt(permit.permit.details.amount)) {
138
149
  const approvalTx = await walletClient.writeContract({
@@ -166,7 +177,7 @@ export async function tradeCoin({
166
177
  primaryType: "PermitSingle",
167
178
  types: PERMIT_SINGLE_TYPES,
168
179
  message,
169
- account,
180
+ account: typeof account === "string" ? account : account.address,
170
181
  });
171
182
  signatures.push({
172
183
  signature,
@@ -71,3 +71,15 @@ export const getCoinsLastTradedUnique = (
71
71
  options?: RequestOptionsType<GetExploreData>,
72
72
  ): Promise<ExploreResponse> =>
73
73
  createExploreQuery(query, "LAST_TRADED_UNIQUE", options);
74
+
75
+ export const getCreatorCoins = (
76
+ query: QueryRequestType = {},
77
+ options?: RequestOptionsType<GetExploreData>,
78
+ ): Promise<ExploreResponse> =>
79
+ createExploreQuery(query, "NEW_CREATORS", options);
80
+
81
+ export const getMostValuableCreatorCoins = (
82
+ query: QueryRequestType = {},
83
+ options?: RequestOptionsType<GetExploreData>,
84
+ ): Promise<ExploreResponse> =>
85
+ createExploreQuery(query, "MOST_VALUABLE_CREATORS", options);
@@ -132,6 +132,17 @@ export type GetCoinResponses = {
132
132
  */
133
133
  decimals?: number;
134
134
  };
135
+ tokenPrice?: {
136
+ /**
137
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
138
+ */
139
+ priceInUsdc?: string;
140
+ currencyAddress: string;
141
+ /**
142
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
143
+ */
144
+ priceInPoolToken: string;
145
+ };
135
146
  /**
136
147
  * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
137
148
  */
@@ -524,6 +535,17 @@ export type GetCoinsResponses = {
524
535
  */
525
536
  decimals?: number;
526
537
  };
538
+ tokenPrice?: {
539
+ /**
540
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
541
+ */
542
+ priceInUsdc?: string;
543
+ currencyAddress: string;
544
+ /**
545
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
546
+ */
547
+ priceInPoolToken: string;
548
+ };
527
549
  /**
528
550
  * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
529
551
  */
@@ -723,7 +745,9 @@ export type GetExploreData = {
723
745
  | "LAST_TRADED"
724
746
  | "LAST_TRADED_UNIQUE"
725
747
  | "FEATURED"
726
- | "FEATURED_VIDEOS";
748
+ | "FEATURED_VIDEOS"
749
+ | "NEW_CREATORS"
750
+ | "MOST_VALUABLE_CREATORS";
727
751
  count?: number;
728
752
  after?: string;
729
753
  };
@@ -814,6 +838,17 @@ export type GetExploreResponses = {
814
838
  */
815
839
  decimals?: number;
816
840
  };
841
+ tokenPrice?: {
842
+ /**
843
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
844
+ */
845
+ priceInUsdc?: string;
846
+ currencyAddress: string;
847
+ /**
848
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
849
+ */
850
+ priceInPoolToken: string;
851
+ };
817
852
  /**
818
853
  * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
819
854
  */
@@ -1017,6 +1052,17 @@ export type GetProfileResponses = {
1017
1052
  };
1018
1053
  }>;
1019
1054
  };
1055
+ creatorCoin?: {
1056
+ address: string;
1057
+ /**
1058
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1059
+ */
1060
+ marketCap: string;
1061
+ /**
1062
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1063
+ */
1064
+ marketCapDelta24h: string;
1065
+ };
1020
1066
  };
1021
1067
  };
1022
1068
  };
@@ -1157,6 +1203,17 @@ export type GetProfileBalancesResponses = {
1157
1203
  */
1158
1204
  decimals?: number;
1159
1205
  };
1206
+ tokenPrice?: {
1207
+ /**
1208
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1209
+ */
1210
+ priceInUsdc?: string;
1211
+ currencyAddress: string;
1212
+ /**
1213
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1214
+ */
1215
+ priceInPoolToken: string;
1216
+ };
1160
1217
  /**
1161
1218
  * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1162
1219
  */
@@ -1390,6 +1447,17 @@ export type GetProfileCoinsResponses = {
1390
1447
  */
1391
1448
  decimals?: number;
1392
1449
  };
1450
+ tokenPrice?: {
1451
+ /**
1452
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1453
+ */
1454
+ priceInUsdc?: string;
1455
+ currencyAddress: string;
1456
+ /**
1457
+ * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1458
+ */
1459
+ priceInPoolToken: string;
1460
+ };
1393
1461
  /**
1394
1462
  * The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1395
1463
  */
@@ -0,0 +1,12 @@
1
+ import { base, baseSepolia, Chain } from "viem/chains";
2
+
3
+ export function getChainFromId(chainId: number): Chain {
4
+ if (chainId === base.id) {
5
+ return base;
6
+ }
7
+ if (chainId === baseSepolia.id) {
8
+ return baseSepolia;
9
+ }
10
+
11
+ throw new Error(`Chain ID ${chainId} not supported`);
12
+ }