anchor-sdk 0.1.36

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +735 -0
  3. package/dist/AnchorApiClient.d.ts +203 -0
  4. package/dist/AnchorApiClient.js +279 -0
  5. package/dist/AnchorApiClientV2.d.ts +270 -0
  6. package/dist/AnchorApiClientV2.js +424 -0
  7. package/dist/AnchorERC1155Client.d.ts +85 -0
  8. package/dist/AnchorERC1155Client.js +280 -0
  9. package/dist/AnchorPayClient.d.ts +79 -0
  10. package/dist/AnchorPayClient.js +217 -0
  11. package/dist/abi/AnchorERC1155.d.ts +1359 -0
  12. package/dist/abi/AnchorERC1155.js +1122 -0
  13. package/dist/abi/AnchorPay.json +452 -0
  14. package/dist/api/AnchorApiHttpClient.d.ts +210 -0
  15. package/dist/api/AnchorApiHttpClient.js +411 -0
  16. package/dist/api/types.d.ts +764 -0
  17. package/dist/api/types.js +2 -0
  18. package/dist/constants.d.ts +49 -0
  19. package/dist/constants.js +221 -0
  20. package/dist/generated/Api.d.ts +1083 -0
  21. package/dist/generated/Api.js +571 -0
  22. package/dist/index.d.ts +341 -0
  23. package/dist/index.js +1377 -0
  24. package/dist/react/AnchorReactSDK.d.ts +59 -0
  25. package/dist/react/AnchorReactSDK.js +181 -0
  26. package/dist/react/index.d.ts +1 -0
  27. package/dist/react/index.js +8 -0
  28. package/dist/typechain/AnchorERC1155.d.ts +999 -0
  29. package/dist/typechain/AnchorERC1155.js +2 -0
  30. package/dist/typechain/AnchorPay.d.ts +242 -0
  31. package/dist/typechain/AnchorPay.js +2 -0
  32. package/dist/typechain/common.d.ts +50 -0
  33. package/dist/typechain/common.js +2 -0
  34. package/dist/typechain/factories/AnchorERC1155__factory.d.ts +1365 -0
  35. package/dist/typechain/factories/AnchorERC1155__factory.js +1766 -0
  36. package/dist/typechain/factories/AnchorPay__factory.d.ts +358 -0
  37. package/dist/typechain/factories/AnchorPay__factory.js +469 -0
  38. package/dist/typechain/factories/index.d.ts +2 -0
  39. package/dist/typechain/factories/index.js +10 -0
  40. package/dist/typechain/index.d.ts +5 -0
  41. package/dist/typechain/index.js +41 -0
  42. package/dist/types.d.ts +109 -0
  43. package/dist/types.js +2 -0
  44. package/package.json +87 -0
@@ -0,0 +1,452 @@
1
+ [
2
+ {
3
+ "type": "constructor",
4
+ "inputs": [],
5
+ "stateMutability": "nonpayable"
6
+ },
7
+ {
8
+ "type": "function",
9
+ "name": "UPGRADE_INTERFACE_VERSION",
10
+ "inputs": [],
11
+ "outputs": [
12
+ {
13
+ "name": "",
14
+ "type": "string",
15
+ "internalType": "string"
16
+ }
17
+ ],
18
+ "stateMutability": "view"
19
+ },
20
+ {
21
+ "type": "function",
22
+ "name": "acceptOwnership",
23
+ "inputs": [],
24
+ "outputs": [],
25
+ "stateMutability": "nonpayable"
26
+ },
27
+ {
28
+ "type": "function",
29
+ "name": "getInterfaceImplementer",
30
+ "inputs": [
31
+ {
32
+ "name": "account",
33
+ "type": "address",
34
+ "internalType": "address"
35
+ },
36
+ {
37
+ "name": "_interfaceHash",
38
+ "type": "bytes32",
39
+ "internalType": "bytes32"
40
+ }
41
+ ],
42
+ "outputs": [
43
+ {
44
+ "name": "",
45
+ "type": "address",
46
+ "internalType": "address"
47
+ }
48
+ ],
49
+ "stateMutability": "view"
50
+ },
51
+ {
52
+ "type": "function",
53
+ "name": "initialize",
54
+ "inputs": [
55
+ {
56
+ "name": "_defaultAdmin",
57
+ "type": "address",
58
+ "internalType": "address"
59
+ }
60
+ ],
61
+ "outputs": [],
62
+ "stateMutability": "nonpayable"
63
+ },
64
+ {
65
+ "type": "function",
66
+ "name": "owner",
67
+ "inputs": [],
68
+ "outputs": [
69
+ {
70
+ "name": "",
71
+ "type": "address",
72
+ "internalType": "address"
73
+ }
74
+ ],
75
+ "stateMutability": "view"
76
+ },
77
+ {
78
+ "type": "function",
79
+ "name": "pause",
80
+ "inputs": [],
81
+ "outputs": [],
82
+ "stateMutability": "nonpayable"
83
+ },
84
+ {
85
+ "type": "function",
86
+ "name": "pendingOwner",
87
+ "inputs": [],
88
+ "outputs": [
89
+ {
90
+ "name": "",
91
+ "type": "address",
92
+ "internalType": "address"
93
+ }
94
+ ],
95
+ "stateMutability": "view"
96
+ },
97
+ {
98
+ "type": "function",
99
+ "name": "proxiableUUID",
100
+ "inputs": [],
101
+ "outputs": [
102
+ {
103
+ "name": "",
104
+ "type": "bytes32",
105
+ "internalType": "bytes32"
106
+ }
107
+ ],
108
+ "stateMutability": "view"
109
+ },
110
+ {
111
+ "type": "function",
112
+ "name": "renounceOwnership",
113
+ "inputs": [],
114
+ "outputs": [],
115
+ "stateMutability": "nonpayable"
116
+ },
117
+ {
118
+ "type": "function",
119
+ "name": "send",
120
+ "inputs": [
121
+ {
122
+ "name": "recipient",
123
+ "type": "address",
124
+ "internalType": "address"
125
+ },
126
+ {
127
+ "name": "token",
128
+ "type": "address",
129
+ "internalType": "address"
130
+ },
131
+ {
132
+ "name": "amount",
133
+ "type": "uint256",
134
+ "internalType": "uint256"
135
+ },
136
+ {
137
+ "name": "data",
138
+ "type": "bytes",
139
+ "internalType": "bytes"
140
+ }
141
+ ],
142
+ "outputs": [],
143
+ "stateMutability": "payable"
144
+ },
145
+ {
146
+ "type": "function",
147
+ "name": "setInterfaceImplementer",
148
+ "inputs": [
149
+ {
150
+ "name": "account",
151
+ "type": "address",
152
+ "internalType": "address"
153
+ },
154
+ {
155
+ "name": "_interfaceHash",
156
+ "type": "bytes32",
157
+ "internalType": "bytes32"
158
+ },
159
+ {
160
+ "name": "implementer",
161
+ "type": "address",
162
+ "internalType": "address"
163
+ }
164
+ ],
165
+ "outputs": [],
166
+ "stateMutability": "nonpayable"
167
+ },
168
+ {
169
+ "type": "function",
170
+ "name": "transferOwnership",
171
+ "inputs": [
172
+ {
173
+ "name": "newOwner",
174
+ "type": "address",
175
+ "internalType": "address"
176
+ }
177
+ ],
178
+ "outputs": [],
179
+ "stateMutability": "nonpayable"
180
+ },
181
+ {
182
+ "type": "function",
183
+ "name": "unpause",
184
+ "inputs": [],
185
+ "outputs": [],
186
+ "stateMutability": "nonpayable"
187
+ },
188
+ {
189
+ "type": "function",
190
+ "name": "upgradeToAndCall",
191
+ "inputs": [
192
+ {
193
+ "name": "newImplementation",
194
+ "type": "address",
195
+ "internalType": "address"
196
+ },
197
+ {
198
+ "name": "data",
199
+ "type": "bytes",
200
+ "internalType": "bytes"
201
+ }
202
+ ],
203
+ "outputs": [],
204
+ "stateMutability": "payable"
205
+ },
206
+ {
207
+ "type": "event",
208
+ "name": "Initialized",
209
+ "inputs": [
210
+ {
211
+ "name": "version",
212
+ "type": "uint64",
213
+ "indexed": false,
214
+ "internalType": "uint64"
215
+ }
216
+ ],
217
+ "anonymous": false
218
+ },
219
+ {
220
+ "type": "event",
221
+ "name": "InterfaceImplementerSet",
222
+ "inputs": [
223
+ {
224
+ "name": "account",
225
+ "type": "address",
226
+ "indexed": true,
227
+ "internalType": "address"
228
+ },
229
+ {
230
+ "name": "interfaceHash",
231
+ "type": "bytes32",
232
+ "indexed": true,
233
+ "internalType": "bytes32"
234
+ },
235
+ {
236
+ "name": "implementer",
237
+ "type": "address",
238
+ "indexed": true,
239
+ "internalType": "address"
240
+ }
241
+ ],
242
+ "anonymous": false
243
+ },
244
+ {
245
+ "type": "event",
246
+ "name": "OwnershipTransferStarted",
247
+ "inputs": [
248
+ {
249
+ "name": "previousOwner",
250
+ "type": "address",
251
+ "indexed": true,
252
+ "internalType": "address"
253
+ },
254
+ {
255
+ "name": "newOwner",
256
+ "type": "address",
257
+ "indexed": true,
258
+ "internalType": "address"
259
+ }
260
+ ],
261
+ "anonymous": false
262
+ },
263
+ {
264
+ "type": "event",
265
+ "name": "OwnershipTransferred",
266
+ "inputs": [
267
+ {
268
+ "name": "previousOwner",
269
+ "type": "address",
270
+ "indexed": true,
271
+ "internalType": "address"
272
+ },
273
+ {
274
+ "name": "newOwner",
275
+ "type": "address",
276
+ "indexed": true,
277
+ "internalType": "address"
278
+ }
279
+ ],
280
+ "anonymous": false
281
+ },
282
+ {
283
+ "type": "event",
284
+ "name": "Paid",
285
+ "inputs": [
286
+ {
287
+ "name": "from",
288
+ "type": "address",
289
+ "indexed": true,
290
+ "internalType": "address"
291
+ },
292
+ {
293
+ "name": "to",
294
+ "type": "address",
295
+ "indexed": true,
296
+ "internalType": "address"
297
+ },
298
+ {
299
+ "name": "amount",
300
+ "type": "uint256",
301
+ "indexed": false,
302
+ "internalType": "uint256"
303
+ },
304
+ {
305
+ "name": "data",
306
+ "type": "bytes",
307
+ "indexed": false,
308
+ "internalType": "bytes"
309
+ }
310
+ ],
311
+ "anonymous": false
312
+ },
313
+ {
314
+ "type": "event",
315
+ "name": "Upgraded",
316
+ "inputs": [
317
+ {
318
+ "name": "implementation",
319
+ "type": "address",
320
+ "indexed": true,
321
+ "internalType": "address"
322
+ }
323
+ ],
324
+ "anonymous": false
325
+ },
326
+ {
327
+ "type": "error",
328
+ "name": "AddressEmptyCode",
329
+ "inputs": [
330
+ {
331
+ "name": "target",
332
+ "type": "address",
333
+ "internalType": "address"
334
+ }
335
+ ]
336
+ },
337
+ {
338
+ "type": "error",
339
+ "name": "AddressNotSet",
340
+ "inputs": []
341
+ },
342
+ {
343
+ "type": "error",
344
+ "name": "ERC1967InvalidImplementation",
345
+ "inputs": [
346
+ {
347
+ "name": "implementation",
348
+ "type": "address",
349
+ "internalType": "address"
350
+ }
351
+ ]
352
+ },
353
+ {
354
+ "type": "error",
355
+ "name": "ERC1967NonPayable",
356
+ "inputs": []
357
+ },
358
+ {
359
+ "type": "error",
360
+ "name": "FailedCall",
361
+ "inputs": []
362
+ },
363
+ {
364
+ "type": "error",
365
+ "name": "InsufficientPayment",
366
+ "inputs": []
367
+ },
368
+ {
369
+ "type": "error",
370
+ "name": "InvalidAddress",
371
+ "inputs": []
372
+ },
373
+ {
374
+ "type": "error",
375
+ "name": "InvalidAmount",
376
+ "inputs": []
377
+ },
378
+ {
379
+ "type": "error",
380
+ "name": "InvalidInitialization",
381
+ "inputs": []
382
+ },
383
+ {
384
+ "type": "error",
385
+ "name": "InvalidMsgValue",
386
+ "inputs": []
387
+ },
388
+ {
389
+ "type": "error",
390
+ "name": "InvalidState",
391
+ "inputs": []
392
+ },
393
+ {
394
+ "type": "error",
395
+ "name": "NotInitializing",
396
+ "inputs": []
397
+ },
398
+ {
399
+ "type": "error",
400
+ "name": "OwnableInvalidOwner",
401
+ "inputs": [
402
+ {
403
+ "name": "owner",
404
+ "type": "address",
405
+ "internalType": "address"
406
+ }
407
+ ]
408
+ },
409
+ {
410
+ "type": "error",
411
+ "name": "OwnableUnauthorizedAccount",
412
+ "inputs": [
413
+ {
414
+ "name": "account",
415
+ "type": "address",
416
+ "internalType": "address"
417
+ }
418
+ ]
419
+ },
420
+ {
421
+ "type": "error",
422
+ "name": "PaymentTransferFailed",
423
+ "inputs": []
424
+ },
425
+ {
426
+ "type": "error",
427
+ "name": "SafeERC20FailedOperation",
428
+ "inputs": [
429
+ {
430
+ "name": "token",
431
+ "type": "address",
432
+ "internalType": "address"
433
+ }
434
+ ]
435
+ },
436
+ {
437
+ "type": "error",
438
+ "name": "UUPSUnauthorizedCallContext",
439
+ "inputs": []
440
+ },
441
+ {
442
+ "type": "error",
443
+ "name": "UUPSUnsupportedProxiableUUID",
444
+ "inputs": [
445
+ {
446
+ "name": "slot",
447
+ "type": "bytes32",
448
+ "internalType": "bytes32"
449
+ }
450
+ ]
451
+ }
452
+ ]
@@ -0,0 +1,210 @@
1
+ import { WebResultBadgeConditionConfigResponse, WebResultBadgeClaimableListResponse, WebResultBadgeAssetsResponse, WebResultBadgeSeriesDetailResponse, WebResultAssetsBadgeResponse, WebResultBadgeClaimableResponse, WebResultBadgeCheckResponse, WebResultBadgeDetailResponse, WebResultBadgeClaimSignatureResponse } from "../generated/Api";
2
+ import { BatchMintRequestVO, MintResponse, NFTMintRequestVO, UserOpHashProcessRequest, WebResultCheckResponse, WebResultCheckResultResponse, WebResultGrantBadgeRequestVO, WebResultGrantBadgeResponseVO, WebResultNftSeriesDetailResponse, WebResultNftSeriesResponse, WebResultTransactionHashProcess, WebResultUserOpHashProcess } from "./types";
3
+ /**
4
+ * Anchor API HTTP 客户端配置
5
+ */
6
+ export interface AnchorApiHttpClientConfig {
7
+ /** API 基础 URL */
8
+ baseUrl: string;
9
+ /** 认证令牌 */
10
+ authToken?: string;
11
+ /** 项目 ID */
12
+ projectId?: string;
13
+ /** 链 ID */
14
+ chainId?: string;
15
+ /** Token 过期回调函数 */
16
+ onTokenExpired?: (error: Error) => void;
17
+ }
18
+ /**
19
+ * Anchor API HTTP 客户端
20
+ * 用于与 Anchor 后端服务进行通信
21
+ *
22
+ * 这个客户端集成了生成的 API 类型和端点,同时保持了
23
+ * 自动 header 注入和配置管理功能。
24
+ */
25
+ export declare class AnchorApiHttpClient {
26
+ private baseUrl;
27
+ private authToken?;
28
+ private projectId?;
29
+ private chainId?;
30
+ private onTokenExpired?;
31
+ private generatedApi;
32
+ /**
33
+ * 创建 Anchor API 客户端
34
+ * @param config 客户端配置
35
+ */
36
+ constructor(config: AnchorApiHttpClientConfig);
37
+ /**
38
+ * 设置认证令牌
39
+ * @param token 认证令牌
40
+ */
41
+ setAuthToken(token: string): void;
42
+ /**
43
+ * 设置 Token 过期回调
44
+ * @param callback Token 过期回调函数
45
+ */
46
+ setTokenExpiredCallback(callback: (error: Error) => void): void;
47
+ /**
48
+ * 设置项目 ID
49
+ * @param projectId 项目 ID
50
+ */
51
+ setProjectId(projectId: string): void;
52
+ /**
53
+ * 设置链 ID
54
+ * @param chainId 链 ID
55
+ */
56
+ setChainId(chainId: string): void;
57
+ /**
58
+ * 创建请求头
59
+ * @returns 请求头对象
60
+ */
61
+ private createHeaders;
62
+ /**
63
+ * 获取请求参数(包含 headers)
64
+ * @returns 请求参数对象
65
+ */
66
+ private getRequestParams;
67
+ /**
68
+ * 处理 API 调用的错误和 token 过期
69
+ * @param apiCall API 调用函数
70
+ * @returns API 调用结果
71
+ */
72
+ private handleApiCall;
73
+ /**
74
+ * 发送 HTTP 请求(用于遗留 API)
75
+ * @param method HTTP 方法
76
+ * @param path 请求路径
77
+ * @param data 请求数据
78
+ * @returns 响应数据
79
+ */
80
+ private request;
81
+ /**
82
+ * 获取徽章条件配置
83
+ * @param platform 平台标识符
84
+ * @param type 条件类型
85
+ * @returns 徽章条件配置响应
86
+ */
87
+ getBadgeConditionConfig(platform: string, type: string): Promise<WebResultBadgeConditionConfigResponse>;
88
+ /**
89
+ * 获取用户可领取徽章
90
+ * @param series 徽章系列过滤器
91
+ * @param limit 每页项目数
92
+ * @param nextToken 分页令牌
93
+ * @returns 徽章可领取列表响应
94
+ */
95
+ getUserClaimableBadges(series?: string, limit?: number, nextToken?: string): Promise<WebResultBadgeClaimableListResponse>;
96
+ /**
97
+ * 获取用户徽章资产
98
+ * @param status 徽章状态过滤器
99
+ * @param strategy 返回策略
100
+ * @param series 徽章系列过滤器
101
+ * @param limit 每页项目数
102
+ * @param nextToken 分页令牌
103
+ * @returns 徽章资产响应
104
+ */
105
+ getUserBadgeAssets(status?: string, strategy?: string, series?: string, limit?: number, nextToken?: string): Promise<WebResultBadgeAssetsResponse>;
106
+ /**
107
+ * 获取徽章系列详情
108
+ * @param seriesId 系列标识符
109
+ * @returns 徽章系列详情响应
110
+ */
111
+ getBadgeSeriesDetail(seriesId: string): Promise<WebResultBadgeSeriesDetailResponse>;
112
+ /**
113
+ * 获取用户资产
114
+ * @param customerIds 用户 ID 列表
115
+ * @param status 资产状态
116
+ * @param strategy 返回策略
117
+ * @param limit 返回数量限制
118
+ * @returns 资产徽章响应
119
+ */
120
+ getUserAssets(customerIds?: string[], status?: string, strategy?: string, limit?: number): Promise<WebResultAssetsBadgeResponse>;
121
+ /**
122
+ * 获取徽章详情
123
+ * @param badgeId 徽章标识符
124
+ * @returns 徽章详情响应
125
+ */
126
+ getBadgeDetail(badgeId: string): Promise<WebResultBadgeDetailResponse>;
127
+ /**
128
+ * 检查单个徽章可领取状态
129
+ * @param badgeId 徽章标识符
130
+ * @returns 徽章可领取响应
131
+ */
132
+ checkSingleBadgeClaimable(badgeId: string): Promise<WebResultBadgeClaimableResponse>;
133
+ /**
134
+ * 检查用户可领取徽章
135
+ * @param data 徽章检查请求
136
+ * @returns 徽章检查响应
137
+ */
138
+ checkUserClaimableBadges(data: any): Promise<WebResultBadgeCheckResponse>;
139
+ /**
140
+ * 获取徽章领取签名
141
+ * @param customerAddress 客户地址
142
+ * @param claimableIds 可领取 ID 列表
143
+ * @returns 徽章领取签名响应
144
+ */
145
+ getBadgeClaimSignatures(customerAddress: string, claimableIds: string[]): Promise<WebResultBadgeClaimSignatureResponse>;
146
+ /**
147
+ * 授予徽章 (Legacy)
148
+ * @param data 授予徽章请求
149
+ * @returns 授予徽章响应
150
+ */
151
+ grantBadge(data: WebResultGrantBadgeRequestVO): Promise<WebResultGrantBadgeResponseVO>;
152
+ /**
153
+ * 获取徽章资产 (Legacy)
154
+ * @param customerId 客户 ID
155
+ * @param status 徽章状态
156
+ * @param strategy 返回策略
157
+ * @returns 徽章资产响应
158
+ */
159
+ badgeAssets(customerId?: string, status?: string, strategy?: string): Promise<WebResultBadgeAssetsResponse>;
160
+ /**
161
+ * 获取 NFT 系列 (Legacy)
162
+ * @param type NFT 类型
163
+ * @returns NFT 系列响应
164
+ */
165
+ nftSeries(type: string): Promise<WebResultNftSeriesResponse>;
166
+ /**
167
+ * 根据 ID 获取 NFT 系列 (Legacy)
168
+ * @param type NFT 类型
169
+ * @param series 系列标识符
170
+ * @param customerId 客户 ID
171
+ * @returns NFT 系列详情响应
172
+ */
173
+ getNftSeriesById(type: string, series: string, customerId?: string): Promise<WebResultNftSeriesDetailResponse>;
174
+ /**
175
+ * 检查徽章 (Legacy)
176
+ * @param type NFT 类型
177
+ * @returns 检查响应
178
+ */
179
+ check(type: string): Promise<WebResultCheckResponse>;
180
+ /**
181
+ * 获取检查结果 (Legacy)
182
+ * @param type NFT 类型
183
+ * @returns 检查结果响应
184
+ */
185
+ getCheckResult(type: string): Promise<WebResultCheckResultResponse>;
186
+ /**
187
+ * 处理用户操作哈希 (Legacy)
188
+ * @param data 用户操作哈希处理请求
189
+ * @returns 用户操作哈希处理响应
190
+ */
191
+ processUserOpHash(data: UserOpHashProcessRequest): Promise<WebResultUserOpHashProcess>;
192
+ /**
193
+ * 处理交易哈希 (Legacy)
194
+ * @param txHash 交易哈希
195
+ * @returns 交易哈希处理响应
196
+ */
197
+ processTransactionHash(txHash: string): Promise<WebResultTransactionHashProcess>;
198
+ /**
199
+ * @deprecated 使用 getBadgeClaimSignatures 替代
200
+ */
201
+ mint(type: string, data: NFTMintRequestVO): Promise<MintResponse>;
202
+ /**
203
+ * @deprecated 使用 getBadgeClaimSignatures 替代
204
+ */
205
+ mintV2(type: string, data: NFTMintRequestVO): Promise<MintResponse>;
206
+ /**
207
+ * @deprecated 使用 getBadgeClaimSignatures 替代
208
+ */
209
+ batchMint(data: BatchMintRequestVO): Promise<MintResponse>;
210
+ }