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,469 @@
1
+ "use strict";
2
+ /* Autogenerated file. Do not edit manually. */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AnchorPay__factory = void 0;
7
+ const ethers_1 = require("ethers");
8
+ const _abi = [
9
+ {
10
+ type: "constructor",
11
+ inputs: [],
12
+ stateMutability: "nonpayable",
13
+ },
14
+ {
15
+ type: "function",
16
+ name: "UPGRADE_INTERFACE_VERSION",
17
+ inputs: [],
18
+ outputs: [
19
+ {
20
+ name: "",
21
+ type: "string",
22
+ internalType: "string",
23
+ },
24
+ ],
25
+ stateMutability: "view",
26
+ },
27
+ {
28
+ type: "function",
29
+ name: "acceptOwnership",
30
+ inputs: [],
31
+ outputs: [],
32
+ stateMutability: "nonpayable",
33
+ },
34
+ {
35
+ type: "function",
36
+ name: "getInterfaceImplementer",
37
+ inputs: [
38
+ {
39
+ name: "account",
40
+ type: "address",
41
+ internalType: "address",
42
+ },
43
+ {
44
+ name: "_interfaceHash",
45
+ type: "bytes32",
46
+ internalType: "bytes32",
47
+ },
48
+ ],
49
+ outputs: [
50
+ {
51
+ name: "",
52
+ type: "address",
53
+ internalType: "address",
54
+ },
55
+ ],
56
+ stateMutability: "view",
57
+ },
58
+ {
59
+ type: "function",
60
+ name: "initialize",
61
+ inputs: [
62
+ {
63
+ name: "_defaultAdmin",
64
+ type: "address",
65
+ internalType: "address",
66
+ },
67
+ ],
68
+ outputs: [],
69
+ stateMutability: "nonpayable",
70
+ },
71
+ {
72
+ type: "function",
73
+ name: "owner",
74
+ inputs: [],
75
+ outputs: [
76
+ {
77
+ name: "",
78
+ type: "address",
79
+ internalType: "address",
80
+ },
81
+ ],
82
+ stateMutability: "view",
83
+ },
84
+ {
85
+ type: "function",
86
+ name: "pause",
87
+ inputs: [],
88
+ outputs: [],
89
+ stateMutability: "nonpayable",
90
+ },
91
+ {
92
+ type: "function",
93
+ name: "pendingOwner",
94
+ inputs: [],
95
+ outputs: [
96
+ {
97
+ name: "",
98
+ type: "address",
99
+ internalType: "address",
100
+ },
101
+ ],
102
+ stateMutability: "view",
103
+ },
104
+ {
105
+ type: "function",
106
+ name: "proxiableUUID",
107
+ inputs: [],
108
+ outputs: [
109
+ {
110
+ name: "",
111
+ type: "bytes32",
112
+ internalType: "bytes32",
113
+ },
114
+ ],
115
+ stateMutability: "view",
116
+ },
117
+ {
118
+ type: "function",
119
+ name: "renounceOwnership",
120
+ inputs: [],
121
+ outputs: [],
122
+ stateMutability: "nonpayable",
123
+ },
124
+ {
125
+ type: "function",
126
+ name: "send",
127
+ inputs: [
128
+ {
129
+ name: "recipient",
130
+ type: "address",
131
+ internalType: "address",
132
+ },
133
+ {
134
+ name: "token",
135
+ type: "address",
136
+ internalType: "address",
137
+ },
138
+ {
139
+ name: "amount",
140
+ type: "uint256",
141
+ internalType: "uint256",
142
+ },
143
+ {
144
+ name: "data",
145
+ type: "bytes",
146
+ internalType: "bytes",
147
+ },
148
+ ],
149
+ outputs: [],
150
+ stateMutability: "payable",
151
+ },
152
+ {
153
+ type: "function",
154
+ name: "setInterfaceImplementer",
155
+ inputs: [
156
+ {
157
+ name: "account",
158
+ type: "address",
159
+ internalType: "address",
160
+ },
161
+ {
162
+ name: "_interfaceHash",
163
+ type: "bytes32",
164
+ internalType: "bytes32",
165
+ },
166
+ {
167
+ name: "implementer",
168
+ type: "address",
169
+ internalType: "address",
170
+ },
171
+ ],
172
+ outputs: [],
173
+ stateMutability: "nonpayable",
174
+ },
175
+ {
176
+ type: "function",
177
+ name: "transferOwnership",
178
+ inputs: [
179
+ {
180
+ name: "newOwner",
181
+ type: "address",
182
+ internalType: "address",
183
+ },
184
+ ],
185
+ outputs: [],
186
+ stateMutability: "nonpayable",
187
+ },
188
+ {
189
+ type: "function",
190
+ name: "unpause",
191
+ inputs: [],
192
+ outputs: [],
193
+ stateMutability: "nonpayable",
194
+ },
195
+ {
196
+ type: "function",
197
+ name: "upgradeToAndCall",
198
+ inputs: [
199
+ {
200
+ name: "newImplementation",
201
+ type: "address",
202
+ internalType: "address",
203
+ },
204
+ {
205
+ name: "data",
206
+ type: "bytes",
207
+ internalType: "bytes",
208
+ },
209
+ ],
210
+ outputs: [],
211
+ stateMutability: "payable",
212
+ },
213
+ {
214
+ type: "event",
215
+ name: "Initialized",
216
+ inputs: [
217
+ {
218
+ name: "version",
219
+ type: "uint64",
220
+ indexed: false,
221
+ internalType: "uint64",
222
+ },
223
+ ],
224
+ anonymous: false,
225
+ },
226
+ {
227
+ type: "event",
228
+ name: "InterfaceImplementerSet",
229
+ inputs: [
230
+ {
231
+ name: "account",
232
+ type: "address",
233
+ indexed: true,
234
+ internalType: "address",
235
+ },
236
+ {
237
+ name: "interfaceHash",
238
+ type: "bytes32",
239
+ indexed: true,
240
+ internalType: "bytes32",
241
+ },
242
+ {
243
+ name: "implementer",
244
+ type: "address",
245
+ indexed: true,
246
+ internalType: "address",
247
+ },
248
+ ],
249
+ anonymous: false,
250
+ },
251
+ {
252
+ type: "event",
253
+ name: "OwnershipTransferStarted",
254
+ inputs: [
255
+ {
256
+ name: "previousOwner",
257
+ type: "address",
258
+ indexed: true,
259
+ internalType: "address",
260
+ },
261
+ {
262
+ name: "newOwner",
263
+ type: "address",
264
+ indexed: true,
265
+ internalType: "address",
266
+ },
267
+ ],
268
+ anonymous: false,
269
+ },
270
+ {
271
+ type: "event",
272
+ name: "OwnershipTransferred",
273
+ inputs: [
274
+ {
275
+ name: "previousOwner",
276
+ type: "address",
277
+ indexed: true,
278
+ internalType: "address",
279
+ },
280
+ {
281
+ name: "newOwner",
282
+ type: "address",
283
+ indexed: true,
284
+ internalType: "address",
285
+ },
286
+ ],
287
+ anonymous: false,
288
+ },
289
+ {
290
+ type: "event",
291
+ name: "Paid",
292
+ inputs: [
293
+ {
294
+ name: "from",
295
+ type: "address",
296
+ indexed: true,
297
+ internalType: "address",
298
+ },
299
+ {
300
+ name: "to",
301
+ type: "address",
302
+ indexed: true,
303
+ internalType: "address",
304
+ },
305
+ {
306
+ name: "amount",
307
+ type: "uint256",
308
+ indexed: false,
309
+ internalType: "uint256",
310
+ },
311
+ {
312
+ name: "data",
313
+ type: "bytes",
314
+ indexed: false,
315
+ internalType: "bytes",
316
+ },
317
+ ],
318
+ anonymous: false,
319
+ },
320
+ {
321
+ type: "event",
322
+ name: "Upgraded",
323
+ inputs: [
324
+ {
325
+ name: "implementation",
326
+ type: "address",
327
+ indexed: true,
328
+ internalType: "address",
329
+ },
330
+ ],
331
+ anonymous: false,
332
+ },
333
+ {
334
+ type: "error",
335
+ name: "AddressEmptyCode",
336
+ inputs: [
337
+ {
338
+ name: "target",
339
+ type: "address",
340
+ internalType: "address",
341
+ },
342
+ ],
343
+ },
344
+ {
345
+ type: "error",
346
+ name: "AddressNotSet",
347
+ inputs: [],
348
+ },
349
+ {
350
+ type: "error",
351
+ name: "ERC1967InvalidImplementation",
352
+ inputs: [
353
+ {
354
+ name: "implementation",
355
+ type: "address",
356
+ internalType: "address",
357
+ },
358
+ ],
359
+ },
360
+ {
361
+ type: "error",
362
+ name: "ERC1967NonPayable",
363
+ inputs: [],
364
+ },
365
+ {
366
+ type: "error",
367
+ name: "FailedCall",
368
+ inputs: [],
369
+ },
370
+ {
371
+ type: "error",
372
+ name: "InsufficientPayment",
373
+ inputs: [],
374
+ },
375
+ {
376
+ type: "error",
377
+ name: "InvalidAddress",
378
+ inputs: [],
379
+ },
380
+ {
381
+ type: "error",
382
+ name: "InvalidAmount",
383
+ inputs: [],
384
+ },
385
+ {
386
+ type: "error",
387
+ name: "InvalidInitialization",
388
+ inputs: [],
389
+ },
390
+ {
391
+ type: "error",
392
+ name: "InvalidMsgValue",
393
+ inputs: [],
394
+ },
395
+ {
396
+ type: "error",
397
+ name: "InvalidState",
398
+ inputs: [],
399
+ },
400
+ {
401
+ type: "error",
402
+ name: "NotInitializing",
403
+ inputs: [],
404
+ },
405
+ {
406
+ type: "error",
407
+ name: "OwnableInvalidOwner",
408
+ inputs: [
409
+ {
410
+ name: "owner",
411
+ type: "address",
412
+ internalType: "address",
413
+ },
414
+ ],
415
+ },
416
+ {
417
+ type: "error",
418
+ name: "OwnableUnauthorizedAccount",
419
+ inputs: [
420
+ {
421
+ name: "account",
422
+ type: "address",
423
+ internalType: "address",
424
+ },
425
+ ],
426
+ },
427
+ {
428
+ type: "error",
429
+ name: "PaymentTransferFailed",
430
+ inputs: [],
431
+ },
432
+ {
433
+ type: "error",
434
+ name: "SafeERC20FailedOperation",
435
+ inputs: [
436
+ {
437
+ name: "token",
438
+ type: "address",
439
+ internalType: "address",
440
+ },
441
+ ],
442
+ },
443
+ {
444
+ type: "error",
445
+ name: "UUPSUnauthorizedCallContext",
446
+ inputs: [],
447
+ },
448
+ {
449
+ type: "error",
450
+ name: "UUPSUnsupportedProxiableUUID",
451
+ inputs: [
452
+ {
453
+ name: "slot",
454
+ type: "bytes32",
455
+ internalType: "bytes32",
456
+ },
457
+ ],
458
+ },
459
+ ];
460
+ class AnchorPay__factory {
461
+ static createInterface() {
462
+ return new ethers_1.Interface(_abi);
463
+ }
464
+ static connect(address, runner) {
465
+ return new ethers_1.Contract(address, _abi, runner);
466
+ }
467
+ }
468
+ exports.AnchorPay__factory = AnchorPay__factory;
469
+ AnchorPay__factory.abi = _abi;
@@ -0,0 +1,2 @@
1
+ export { AnchorERC1155__factory } from "./AnchorERC1155__factory";
2
+ export { AnchorPay__factory } from "./AnchorPay__factory";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnchorPay__factory = exports.AnchorERC1155__factory = void 0;
4
+ /* Autogenerated file. Do not edit manually. */
5
+ /* tslint:disable */
6
+ /* eslint-disable */
7
+ var AnchorERC1155__factory_1 = require("./AnchorERC1155__factory");
8
+ Object.defineProperty(exports, "AnchorERC1155__factory", { enumerable: true, get: function () { return AnchorERC1155__factory_1.AnchorERC1155__factory; } });
9
+ var AnchorPay__factory_1 = require("./AnchorPay__factory");
10
+ Object.defineProperty(exports, "AnchorPay__factory", { enumerable: true, get: function () { return AnchorPay__factory_1.AnchorPay__factory; } });
@@ -0,0 +1,5 @@
1
+ export type { AnchorERC1155 } from "./AnchorERC1155";
2
+ export type { AnchorPay } from "./AnchorPay";
3
+ export * as factories from "./factories";
4
+ export { AnchorERC1155__factory } from "./factories/AnchorERC1155__factory";
5
+ export { AnchorPay__factory } from "./factories/AnchorPay__factory";
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AnchorPay__factory = exports.AnchorERC1155__factory = exports.factories = void 0;
37
+ exports.factories = __importStar(require("./factories"));
38
+ var AnchorERC1155__factory_1 = require("./factories/AnchorERC1155__factory");
39
+ Object.defineProperty(exports, "AnchorERC1155__factory", { enumerable: true, get: function () { return AnchorERC1155__factory_1.AnchorERC1155__factory; } });
40
+ var AnchorPay__factory_1 = require("./factories/AnchorPay__factory");
41
+ Object.defineProperty(exports, "AnchorPay__factory", { enumerable: true, get: function () { return AnchorPay__factory_1.AnchorPay__factory; } });
@@ -0,0 +1,109 @@
1
+ import { Account, Address, Hex, PublicClient, WalletClient } from "viem";
2
+ import { Environment } from "./constants";
3
+ /**
4
+ * 环境配置
5
+ */
6
+ export interface EnvironmentConfig {
7
+ /** API 基础 URL */
8
+ apiBaseUrl: string;
9
+ /** 各网络的合约地址 */
10
+ contracts: Record<string, AnchorContractsInterface>;
11
+ }
12
+ /**
13
+ * Anchor 合约地址配置接口
14
+ */
15
+ export interface AnchorContractsInterface {
16
+ /** AnchorPay 合约地址 */
17
+ anchorPay?: string;
18
+ /** AnchorERC1155 合约地址 */
19
+ anchorERC1155?: string;
20
+ }
21
+ /**
22
+ * SDK 配置
23
+ */
24
+ export interface AnchorSDKConfig {
25
+ /** Provider URL or Web3 Provider (e.g., window.ethereum) */
26
+ provider?: string | any;
27
+ /** Optional signer or wallet for transactions (defaults to provider if not provided) */
28
+ signer?: any;
29
+ /** Network information */
30
+ network: {
31
+ id: number;
32
+ name: string;
33
+ [key: string]: any;
34
+ };
35
+ /** 环境枚举 */
36
+ env: Environment;
37
+ /** API 基础 URL(如果不提供,将使用环境配置中的 URL) */
38
+ apiBaseUrl?: string;
39
+ /** 认证令牌(用于 API 调用) */
40
+ authToken?: string;
41
+ /** 项目 ID(用于 API 调用)- 新的标准化头部 */
42
+ projectId?: string;
43
+ /** AnchorPay 合约地址(如果不提供,将使用环境配置中的地址) */
44
+ anchorPayAddress?: string;
45
+ /** AnchorERC1155 合约地址(如果不提供,将使用环境配置中的地址) */
46
+ anchorERC1155Address?: string;
47
+ /** 公共客户端(只读操作) */
48
+ publicClient?: PublicClient;
49
+ /** 钱包客户端(写入操作,包含账户信息) */
50
+ walletClient?: WalletClient;
51
+ /** 账户信息 */
52
+ account?: Account;
53
+ /** Token 过期回调函数 */
54
+ onTokenExpired?: (error: Error) => void;
55
+ }
56
+ /**
57
+ * 铸造请求
58
+ */
59
+ export interface IMintRequest {
60
+ /** 接收者地址 */
61
+ to: Address;
62
+ /** 代币ID */
63
+ tokenId: number | bigint;
64
+ /** 数量 */
65
+ quantity: number | bigint;
66
+ /** 价格 */
67
+ price: bigint;
68
+ /** 货币地址(ETH为零地址) */
69
+ currency: Address;
70
+ /** 有效期开始时间戳 */
71
+ validityStartTimestamp?: number | bigint;
72
+ /** 有效期结束时间戳 */
73
+ validityEndTimestamp?: number | bigint;
74
+ /** 有效期(时间戳)- 兼容旧版本 */
75
+ validUntil?: number | bigint;
76
+ /** 唯一ID */
77
+ uid: Hex;
78
+ chainId: bigint;
79
+ contractAddress?: string;
80
+ projectHandle?: string;
81
+ }
82
+ /**
83
+ * 签名铸造请求
84
+ */
85
+ export interface SignedMintRequest {
86
+ /** 铸造请求 */
87
+ request: IMintRequest;
88
+ /** 签名 */
89
+ signature: string;
90
+ }
91
+ /**
92
+ * 支付选项
93
+ */
94
+ export interface PaymentOptions {
95
+ /** 是否自动批准ERC20代币(仅在使用ERC20代币支付时有效) */
96
+ autoApprove?: boolean;
97
+ /** Gas限制 */
98
+ gas?: bigint;
99
+ /** 最大Gas费用 */
100
+ maxFeePerGas?: bigint;
101
+ /** 最大优先费用 */
102
+ maxPriorityFeePerGas?: bigint;
103
+ /** 交易值 */
104
+ value?: bigint;
105
+ /** 交易nonce */
106
+ nonce?: number;
107
+ /** 是否直接发送交易(true: 发送交易并返回交易哈希,false: 只返回交易数据不发送) */
108
+ sendTransaction?: boolean;
109
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });