multicoyn-sdk 0.1.0 → 0.1.2
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/App.d.ts +2 -0
- package/dist/components/MulticoynButton.d.ts +14 -0
- package/dist/components/PaymentModal.d.ts +16 -0
- package/dist/components/PaymentSummary.d.ts +7 -0
- package/dist/components/TokenSlider.d.ts +8 -0
- package/dist/components/icons/CloseIcon.d.ts +6 -0
- package/dist/components/icons/InfoIcon.d.ts +6 -0
- package/dist/components/icons/ProcessingIcon.d.ts +6 -0
- package/dist/components/icons/SearchIcon.d.ts +6 -0
- package/dist/components/icons/SuccessIcon.d.ts +6 -0
- package/dist/components/icons/index.d.ts +5 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/types.d.ts +42 -0
- package/dist/config/abis.d.ts +189 -0
- package/dist/config/chains.d.ts +47 -0
- package/dist/config/contracts.d.ts +12 -0
- package/dist/config/wagmi.d.ts +2 -0
- package/dist/constants/payment.d.ts +38 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/useERC20.d.ts +286 -0
- package/dist/hooks/useMultiTokenBalances.d.ts +10 -0
- package/dist/hooks/useMultiTokenPrices.d.ts +17 -0
- package/dist/hooks/usePaymentModal.d.ts +11 -0
- package/dist/hooks/usePaymentRouter.d.ts +254 -0
- package/dist/hooks/useTokenRegistry.d.ts +409 -0
- package/dist/index.d.ts +11 -0
- package/dist/lib/errors.d.ts +6 -0
- package/dist/lib/tokens.d.ts +9 -0
- package/dist/main.d.ts +1 -0
- package/dist/providers/PaymentContext.d.ts +11 -0
- package/dist/providers/PaymentProvider.d.ts +6 -0
- package/dist/providers/Web3Provider.d.ts +6 -0
- package/dist/providers/usePaymentConfig.d.ts +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
export declare function useTokenRegistry(): {
|
|
2
|
+
registerToken: (tokenAddress: `0x${string}`, chainlinkFeed: `0x${string}`, symbol: string, decimals: number) => void;
|
|
3
|
+
setTokenEnabled: (tokenAddress: `0x${string}`, enabled: boolean) => void;
|
|
4
|
+
updatePriceFeed: (tokenAddress: `0x${string}`, newPriceFeed: `0x${string}`) => void;
|
|
5
|
+
setMinPaymentAmount: (tokenAddress: `0x${string}`, minAmount: bigint) => void;
|
|
6
|
+
grantRole: (role: `0x${string}`, account: `0x${string}`) => void;
|
|
7
|
+
revokeRole: (role: `0x${string}`, account: `0x${string}`) => void;
|
|
8
|
+
useGetTokenConfig: (tokenAddress: `0x${string}`) => import("wagmi").UseReadContractReturnType<({
|
|
9
|
+
inputs: never[];
|
|
10
|
+
stateMutability: string;
|
|
11
|
+
type: string;
|
|
12
|
+
name?: undefined;
|
|
13
|
+
anonymous?: undefined;
|
|
14
|
+
outputs?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
inputs: {
|
|
17
|
+
internalType: string;
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
}[];
|
|
21
|
+
name: string;
|
|
22
|
+
type: string;
|
|
23
|
+
stateMutability?: undefined;
|
|
24
|
+
anonymous?: undefined;
|
|
25
|
+
outputs?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
anonymous: boolean;
|
|
28
|
+
inputs: {
|
|
29
|
+
indexed: boolean;
|
|
30
|
+
internalType: string;
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
}[];
|
|
34
|
+
name: string;
|
|
35
|
+
type: string;
|
|
36
|
+
stateMutability?: undefined;
|
|
37
|
+
outputs?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
inputs: {
|
|
40
|
+
internalType: string;
|
|
41
|
+
name: string;
|
|
42
|
+
type: string;
|
|
43
|
+
}[];
|
|
44
|
+
name: string;
|
|
45
|
+
outputs: {
|
|
46
|
+
internalType: string;
|
|
47
|
+
name: string;
|
|
48
|
+
type: string;
|
|
49
|
+
}[];
|
|
50
|
+
stateMutability: string;
|
|
51
|
+
type: string;
|
|
52
|
+
anonymous?: undefined;
|
|
53
|
+
} | {
|
|
54
|
+
inputs: {
|
|
55
|
+
internalType: string;
|
|
56
|
+
name: string;
|
|
57
|
+
type: string;
|
|
58
|
+
}[];
|
|
59
|
+
name: string;
|
|
60
|
+
outputs: {
|
|
61
|
+
components: {
|
|
62
|
+
internalType: string;
|
|
63
|
+
name: string;
|
|
64
|
+
type: string;
|
|
65
|
+
}[];
|
|
66
|
+
internalType: string;
|
|
67
|
+
name: string;
|
|
68
|
+
type: string;
|
|
69
|
+
}[];
|
|
70
|
+
stateMutability: string;
|
|
71
|
+
type: string;
|
|
72
|
+
anonymous?: undefined;
|
|
73
|
+
})[], "getTokenConfig", `0x${string}`[], unknown>;
|
|
74
|
+
useGetTokenPrice: (tokenAddress: `0x${string}`) => import("wagmi").UseReadContractReturnType<({
|
|
75
|
+
inputs: never[];
|
|
76
|
+
stateMutability: string;
|
|
77
|
+
type: string;
|
|
78
|
+
name?: undefined;
|
|
79
|
+
anonymous?: undefined;
|
|
80
|
+
outputs?: undefined;
|
|
81
|
+
} | {
|
|
82
|
+
inputs: {
|
|
83
|
+
internalType: string;
|
|
84
|
+
name: string;
|
|
85
|
+
type: string;
|
|
86
|
+
}[];
|
|
87
|
+
name: string;
|
|
88
|
+
type: string;
|
|
89
|
+
stateMutability?: undefined;
|
|
90
|
+
anonymous?: undefined;
|
|
91
|
+
outputs?: undefined;
|
|
92
|
+
} | {
|
|
93
|
+
anonymous: boolean;
|
|
94
|
+
inputs: {
|
|
95
|
+
indexed: boolean;
|
|
96
|
+
internalType: string;
|
|
97
|
+
name: string;
|
|
98
|
+
type: string;
|
|
99
|
+
}[];
|
|
100
|
+
name: string;
|
|
101
|
+
type: string;
|
|
102
|
+
stateMutability?: undefined;
|
|
103
|
+
outputs?: undefined;
|
|
104
|
+
} | {
|
|
105
|
+
inputs: {
|
|
106
|
+
internalType: string;
|
|
107
|
+
name: string;
|
|
108
|
+
type: string;
|
|
109
|
+
}[];
|
|
110
|
+
name: string;
|
|
111
|
+
outputs: {
|
|
112
|
+
internalType: string;
|
|
113
|
+
name: string;
|
|
114
|
+
type: string;
|
|
115
|
+
}[];
|
|
116
|
+
stateMutability: string;
|
|
117
|
+
type: string;
|
|
118
|
+
anonymous?: undefined;
|
|
119
|
+
} | {
|
|
120
|
+
inputs: {
|
|
121
|
+
internalType: string;
|
|
122
|
+
name: string;
|
|
123
|
+
type: string;
|
|
124
|
+
}[];
|
|
125
|
+
name: string;
|
|
126
|
+
outputs: {
|
|
127
|
+
components: {
|
|
128
|
+
internalType: string;
|
|
129
|
+
name: string;
|
|
130
|
+
type: string;
|
|
131
|
+
}[];
|
|
132
|
+
internalType: string;
|
|
133
|
+
name: string;
|
|
134
|
+
type: string;
|
|
135
|
+
}[];
|
|
136
|
+
stateMutability: string;
|
|
137
|
+
type: string;
|
|
138
|
+
anonymous?: undefined;
|
|
139
|
+
})[], "getTokenPriceUSD", `0x${string}`[], unknown>;
|
|
140
|
+
useGetRegisteredTokens: () => import("wagmi").UseReadContractReturnType<({
|
|
141
|
+
inputs: never[];
|
|
142
|
+
stateMutability: string;
|
|
143
|
+
type: string;
|
|
144
|
+
name?: undefined;
|
|
145
|
+
anonymous?: undefined;
|
|
146
|
+
outputs?: undefined;
|
|
147
|
+
} | {
|
|
148
|
+
inputs: {
|
|
149
|
+
internalType: string;
|
|
150
|
+
name: string;
|
|
151
|
+
type: string;
|
|
152
|
+
}[];
|
|
153
|
+
name: string;
|
|
154
|
+
type: string;
|
|
155
|
+
stateMutability?: undefined;
|
|
156
|
+
anonymous?: undefined;
|
|
157
|
+
outputs?: undefined;
|
|
158
|
+
} | {
|
|
159
|
+
anonymous: boolean;
|
|
160
|
+
inputs: {
|
|
161
|
+
indexed: boolean;
|
|
162
|
+
internalType: string;
|
|
163
|
+
name: string;
|
|
164
|
+
type: string;
|
|
165
|
+
}[];
|
|
166
|
+
name: string;
|
|
167
|
+
type: string;
|
|
168
|
+
stateMutability?: undefined;
|
|
169
|
+
outputs?: undefined;
|
|
170
|
+
} | {
|
|
171
|
+
inputs: {
|
|
172
|
+
internalType: string;
|
|
173
|
+
name: string;
|
|
174
|
+
type: string;
|
|
175
|
+
}[];
|
|
176
|
+
name: string;
|
|
177
|
+
outputs: {
|
|
178
|
+
internalType: string;
|
|
179
|
+
name: string;
|
|
180
|
+
type: string;
|
|
181
|
+
}[];
|
|
182
|
+
stateMutability: string;
|
|
183
|
+
type: string;
|
|
184
|
+
anonymous?: undefined;
|
|
185
|
+
} | {
|
|
186
|
+
inputs: {
|
|
187
|
+
internalType: string;
|
|
188
|
+
name: string;
|
|
189
|
+
type: string;
|
|
190
|
+
}[];
|
|
191
|
+
name: string;
|
|
192
|
+
outputs: {
|
|
193
|
+
components: {
|
|
194
|
+
internalType: string;
|
|
195
|
+
name: string;
|
|
196
|
+
type: string;
|
|
197
|
+
}[];
|
|
198
|
+
internalType: string;
|
|
199
|
+
name: string;
|
|
200
|
+
type: string;
|
|
201
|
+
}[];
|
|
202
|
+
stateMutability: string;
|
|
203
|
+
type: string;
|
|
204
|
+
anonymous?: undefined;
|
|
205
|
+
})[], "getRegisteredTokens", readonly unknown[], unknown>;
|
|
206
|
+
useGetRegisteredTokenCount: () => import("wagmi").UseReadContractReturnType<({
|
|
207
|
+
inputs: never[];
|
|
208
|
+
stateMutability: string;
|
|
209
|
+
type: string;
|
|
210
|
+
name?: undefined;
|
|
211
|
+
anonymous?: undefined;
|
|
212
|
+
outputs?: undefined;
|
|
213
|
+
} | {
|
|
214
|
+
inputs: {
|
|
215
|
+
internalType: string;
|
|
216
|
+
name: string;
|
|
217
|
+
type: string;
|
|
218
|
+
}[];
|
|
219
|
+
name: string;
|
|
220
|
+
type: string;
|
|
221
|
+
stateMutability?: undefined;
|
|
222
|
+
anonymous?: undefined;
|
|
223
|
+
outputs?: undefined;
|
|
224
|
+
} | {
|
|
225
|
+
anonymous: boolean;
|
|
226
|
+
inputs: {
|
|
227
|
+
indexed: boolean;
|
|
228
|
+
internalType: string;
|
|
229
|
+
name: string;
|
|
230
|
+
type: string;
|
|
231
|
+
}[];
|
|
232
|
+
name: string;
|
|
233
|
+
type: string;
|
|
234
|
+
stateMutability?: undefined;
|
|
235
|
+
outputs?: undefined;
|
|
236
|
+
} | {
|
|
237
|
+
inputs: {
|
|
238
|
+
internalType: string;
|
|
239
|
+
name: string;
|
|
240
|
+
type: string;
|
|
241
|
+
}[];
|
|
242
|
+
name: string;
|
|
243
|
+
outputs: {
|
|
244
|
+
internalType: string;
|
|
245
|
+
name: string;
|
|
246
|
+
type: string;
|
|
247
|
+
}[];
|
|
248
|
+
stateMutability: string;
|
|
249
|
+
type: string;
|
|
250
|
+
anonymous?: undefined;
|
|
251
|
+
} | {
|
|
252
|
+
inputs: {
|
|
253
|
+
internalType: string;
|
|
254
|
+
name: string;
|
|
255
|
+
type: string;
|
|
256
|
+
}[];
|
|
257
|
+
name: string;
|
|
258
|
+
outputs: {
|
|
259
|
+
components: {
|
|
260
|
+
internalType: string;
|
|
261
|
+
name: string;
|
|
262
|
+
type: string;
|
|
263
|
+
}[];
|
|
264
|
+
internalType: string;
|
|
265
|
+
name: string;
|
|
266
|
+
type: string;
|
|
267
|
+
}[];
|
|
268
|
+
stateMutability: string;
|
|
269
|
+
type: string;
|
|
270
|
+
anonymous?: undefined;
|
|
271
|
+
})[], "getRegisteredTokenCount", readonly unknown[], unknown>;
|
|
272
|
+
useIsTokenEnabled: (tokenAddress: `0x${string}`) => import("wagmi").UseReadContractReturnType<({
|
|
273
|
+
inputs: never[];
|
|
274
|
+
stateMutability: string;
|
|
275
|
+
type: string;
|
|
276
|
+
name?: undefined;
|
|
277
|
+
anonymous?: undefined;
|
|
278
|
+
outputs?: undefined;
|
|
279
|
+
} | {
|
|
280
|
+
inputs: {
|
|
281
|
+
internalType: string;
|
|
282
|
+
name: string;
|
|
283
|
+
type: string;
|
|
284
|
+
}[];
|
|
285
|
+
name: string;
|
|
286
|
+
type: string;
|
|
287
|
+
stateMutability?: undefined;
|
|
288
|
+
anonymous?: undefined;
|
|
289
|
+
outputs?: undefined;
|
|
290
|
+
} | {
|
|
291
|
+
anonymous: boolean;
|
|
292
|
+
inputs: {
|
|
293
|
+
indexed: boolean;
|
|
294
|
+
internalType: string;
|
|
295
|
+
name: string;
|
|
296
|
+
type: string;
|
|
297
|
+
}[];
|
|
298
|
+
name: string;
|
|
299
|
+
type: string;
|
|
300
|
+
stateMutability?: undefined;
|
|
301
|
+
outputs?: undefined;
|
|
302
|
+
} | {
|
|
303
|
+
inputs: {
|
|
304
|
+
internalType: string;
|
|
305
|
+
name: string;
|
|
306
|
+
type: string;
|
|
307
|
+
}[];
|
|
308
|
+
name: string;
|
|
309
|
+
outputs: {
|
|
310
|
+
internalType: string;
|
|
311
|
+
name: string;
|
|
312
|
+
type: string;
|
|
313
|
+
}[];
|
|
314
|
+
stateMutability: string;
|
|
315
|
+
type: string;
|
|
316
|
+
anonymous?: undefined;
|
|
317
|
+
} | {
|
|
318
|
+
inputs: {
|
|
319
|
+
internalType: string;
|
|
320
|
+
name: string;
|
|
321
|
+
type: string;
|
|
322
|
+
}[];
|
|
323
|
+
name: string;
|
|
324
|
+
outputs: {
|
|
325
|
+
components: {
|
|
326
|
+
internalType: string;
|
|
327
|
+
name: string;
|
|
328
|
+
type: string;
|
|
329
|
+
}[];
|
|
330
|
+
internalType: string;
|
|
331
|
+
name: string;
|
|
332
|
+
type: string;
|
|
333
|
+
}[];
|
|
334
|
+
stateMutability: string;
|
|
335
|
+
type: string;
|
|
336
|
+
anonymous?: undefined;
|
|
337
|
+
})[], "isTokenEnabled", `0x${string}`[], unknown>;
|
|
338
|
+
useHasRole: (role: `0x${string}`, account: `0x${string}`) => import("wagmi").UseReadContractReturnType<({
|
|
339
|
+
inputs: never[];
|
|
340
|
+
stateMutability: string;
|
|
341
|
+
type: string;
|
|
342
|
+
name?: undefined;
|
|
343
|
+
anonymous?: undefined;
|
|
344
|
+
outputs?: undefined;
|
|
345
|
+
} | {
|
|
346
|
+
inputs: {
|
|
347
|
+
internalType: string;
|
|
348
|
+
name: string;
|
|
349
|
+
type: string;
|
|
350
|
+
}[];
|
|
351
|
+
name: string;
|
|
352
|
+
type: string;
|
|
353
|
+
stateMutability?: undefined;
|
|
354
|
+
anonymous?: undefined;
|
|
355
|
+
outputs?: undefined;
|
|
356
|
+
} | {
|
|
357
|
+
anonymous: boolean;
|
|
358
|
+
inputs: {
|
|
359
|
+
indexed: boolean;
|
|
360
|
+
internalType: string;
|
|
361
|
+
name: string;
|
|
362
|
+
type: string;
|
|
363
|
+
}[];
|
|
364
|
+
name: string;
|
|
365
|
+
type: string;
|
|
366
|
+
stateMutability?: undefined;
|
|
367
|
+
outputs?: undefined;
|
|
368
|
+
} | {
|
|
369
|
+
inputs: {
|
|
370
|
+
internalType: string;
|
|
371
|
+
name: string;
|
|
372
|
+
type: string;
|
|
373
|
+
}[];
|
|
374
|
+
name: string;
|
|
375
|
+
outputs: {
|
|
376
|
+
internalType: string;
|
|
377
|
+
name: string;
|
|
378
|
+
type: string;
|
|
379
|
+
}[];
|
|
380
|
+
stateMutability: string;
|
|
381
|
+
type: string;
|
|
382
|
+
anonymous?: undefined;
|
|
383
|
+
} | {
|
|
384
|
+
inputs: {
|
|
385
|
+
internalType: string;
|
|
386
|
+
name: string;
|
|
387
|
+
type: string;
|
|
388
|
+
}[];
|
|
389
|
+
name: string;
|
|
390
|
+
outputs: {
|
|
391
|
+
components: {
|
|
392
|
+
internalType: string;
|
|
393
|
+
name: string;
|
|
394
|
+
type: string;
|
|
395
|
+
}[];
|
|
396
|
+
internalType: string;
|
|
397
|
+
name: string;
|
|
398
|
+
type: string;
|
|
399
|
+
}[];
|
|
400
|
+
stateMutability: string;
|
|
401
|
+
type: string;
|
|
402
|
+
anonymous?: undefined;
|
|
403
|
+
})[], "hasRole", `0x${string}`[], unknown>;
|
|
404
|
+
hash: `0x${string}` | undefined;
|
|
405
|
+
isPending: boolean;
|
|
406
|
+
isConfirming: boolean;
|
|
407
|
+
isConfirmed: boolean;
|
|
408
|
+
error: import("@wagmi/core").WriteContractErrorType | null;
|
|
409
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { MulticoynButton } from './components/MulticoynButton';
|
|
2
|
+
export { PaymentSummary } from './components/PaymentSummary';
|
|
3
|
+
export { Web3Provider } from './providers/Web3Provider';
|
|
4
|
+
export { PaymentProvider } from './providers/PaymentProvider';
|
|
5
|
+
export { usePaymentConfig } from './providers/usePaymentConfig';
|
|
6
|
+
export * from './hooks';
|
|
7
|
+
export type * from './components/types';
|
|
8
|
+
export { CONTRACTS, TOKENS } from './config/contracts';
|
|
9
|
+
export { wagmiConfig } from './config/wagmi';
|
|
10
|
+
export { liskSepolia } from './config/chains';
|
|
11
|
+
export * from './constants/payment';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Token } from '../components/types';
|
|
2
|
+
export declare function calculateTokenAmount(usdValue: number, priceUSD: number, decimals: number): bigint;
|
|
3
|
+
export declare function calculateUSDValue(tokenAmount: bigint, priceUSD: number, decimals: number): number;
|
|
4
|
+
export declare function formatTokenAmount(amount: bigint, decimals: number): string;
|
|
5
|
+
export declare function validateTokenSelection(tokens: Token[]): {
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function scaleUSDAmount(usdAmount: number): bigint;
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index.css";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface PaymentConfig {
|
|
2
|
+
merchantAddress?: `0x${string}`;
|
|
3
|
+
settleInIDR?: boolean;
|
|
4
|
+
enabledTokens?: string[];
|
|
5
|
+
theme?: "light" | "dark";
|
|
6
|
+
}
|
|
7
|
+
export interface PaymentContextValue {
|
|
8
|
+
config: PaymentConfig;
|
|
9
|
+
updateConfig: (config: Partial<PaymentConfig>) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const PaymentContext: import("react").Context<PaymentContextValue | undefined>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { PaymentConfig } from "./PaymentContext";
|
|
3
|
+
export declare function PaymentProvider({ children, initialConfig, }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
initialConfig?: PaymentConfig;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function usePaymentConfig(): import("./PaymentContext").PaymentContextValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "multicoyn-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Multicoyn SDK for Web3 payments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
14
|
},
|
|
15
|
-
"./styles": "./dist/
|
|
15
|
+
"./styles": "./dist/multicoyn-sdk.css"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"dev": "vite",
|
|
22
22
|
"build": "tsc && vite build",
|
|
23
|
-
"build:lib": "vite build",
|
|
23
|
+
"build:lib": "vite build && tsc --project tsconfig.app.json --outDir dist",
|
|
24
24
|
"lint": "eslint .",
|
|
25
25
|
"preview": "vite preview",
|
|
26
26
|
"prepublishOnly": "npm run build:lib"
|