@1money/protocol-ts-sdk 1.1.2-alpha.7 → 2.0.0

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 (68) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/README.md +244 -134
  3. package/es/__integration__/helpers.d.ts +0 -7
  4. package/es/api/checkpoints/types.d.ts +0 -1
  5. package/es/api/index.js +17 -10
  6. package/es/api/tokens/index.d.ts +7 -1
  7. package/es/api/tokens/types.d.ts +21 -6
  8. package/es/api/transactions/index.d.ts +4 -3
  9. package/es/api/transactions/types.d.ts +14 -5
  10. package/es/client/index.js +4 -4
  11. package/es/index.d.ts +1 -0
  12. package/es/index.js +481 -22
  13. package/es/signing/builders/index.d.ts +11 -0
  14. package/es/signing/builders/payment.d.ts +3 -0
  15. package/es/signing/builders/tokenAuthority.d.ts +3 -0
  16. package/es/signing/builders/tokenBridgeAndMint.d.ts +3 -0
  17. package/es/signing/builders/tokenBurn.d.ts +3 -0
  18. package/es/signing/builders/tokenBurnAndBridge.d.ts +3 -0
  19. package/es/signing/builders/tokenClawback.d.ts +3 -0
  20. package/es/signing/builders/tokenIssue.d.ts +3 -0
  21. package/es/signing/builders/tokenManageList.d.ts +3 -0
  22. package/es/signing/builders/tokenMetadata.d.ts +3 -0
  23. package/es/signing/builders/tokenMint.d.ts +3 -0
  24. package/es/signing/builders/tokenPause.d.ts +3 -0
  25. package/es/signing/builders/validate.d.ts +18 -0
  26. package/es/signing/core.d.ts +27 -0
  27. package/es/signing/index.d.ts +18 -0
  28. package/es/signing/signer.d.ts +3 -0
  29. package/es/utils/encode.d.ts +11 -0
  30. package/es/utils/index.d.ts +2 -1
  31. package/es/utils/index.js +90 -10
  32. package/es/utils/interface.d.ts +27 -0
  33. package/es/utils/sign.d.ts +6 -1
  34. package/lib/__integration__/helpers.d.ts +0 -7
  35. package/lib/api/checkpoints/types.d.ts +0 -1
  36. package/lib/api/index.js +17 -10
  37. package/lib/api/tokens/index.d.ts +7 -1
  38. package/lib/api/tokens/types.d.ts +21 -6
  39. package/lib/api/transactions/index.d.ts +4 -3
  40. package/lib/api/transactions/types.d.ts +14 -5
  41. package/lib/client/index.js +4 -4
  42. package/lib/index.d.ts +1 -0
  43. package/lib/index.js +469 -21
  44. package/lib/signing/builders/index.d.ts +11 -0
  45. package/lib/signing/builders/payment.d.ts +3 -0
  46. package/lib/signing/builders/tokenAuthority.d.ts +3 -0
  47. package/lib/signing/builders/tokenBridgeAndMint.d.ts +3 -0
  48. package/lib/signing/builders/tokenBurn.d.ts +3 -0
  49. package/lib/signing/builders/tokenBurnAndBridge.d.ts +3 -0
  50. package/lib/signing/builders/tokenClawback.d.ts +3 -0
  51. package/lib/signing/builders/tokenIssue.d.ts +3 -0
  52. package/lib/signing/builders/tokenManageList.d.ts +3 -0
  53. package/lib/signing/builders/tokenMetadata.d.ts +3 -0
  54. package/lib/signing/builders/tokenMint.d.ts +3 -0
  55. package/lib/signing/builders/tokenPause.d.ts +3 -0
  56. package/lib/signing/builders/validate.d.ts +18 -0
  57. package/lib/signing/core.d.ts +27 -0
  58. package/lib/signing/index.d.ts +18 -0
  59. package/lib/signing/signer.d.ts +3 -0
  60. package/lib/utils/encode.d.ts +11 -0
  61. package/lib/utils/index.d.ts +2 -1
  62. package/lib/utils/index.js +90 -10
  63. package/lib/utils/interface.d.ts +27 -0
  64. package/lib/utils/sign.d.ts +6 -1
  65. package/package.json +2 -2
  66. package/umd/1money-protocol-ts-sdk.min.js +3 -2
  67. package/.env.integration +0 -16
  68. package/umd/1money-ts-sdk.min.js +0 -2
@@ -19,7 +19,8 @@
19
19
  "Bash(cat:*)",
20
20
  "Bash(xargs grep:*)",
21
21
  "Bash(npm run lint:es_fix:*)",
22
- "Bash(node test-encoding.mjs:*)"
22
+ "Bash(node test-encoding.mjs:*)",
23
+ "Bash(npm test:*)"
23
24
  ],
24
25
  "deny": []
25
26
  }
package/README.md CHANGED
@@ -37,6 +37,34 @@ const apiClient = api({
37
37
  });
38
38
  ```
39
39
 
40
+ ### Configure Custom HTTP Headers
41
+
42
+ You can set custom HTTP headers that will be included in all API requests:
43
+
44
+ ```typescript
45
+ import { setInitConfig } from '@1money/protocol-ts-sdk';
46
+
47
+ // Set custom headers for all requests
48
+ setInitConfig({
49
+ headers: {
50
+ 'Authorization': 'Bearer your-token',
51
+ 'X-Custom-Header': 'custom-value'
52
+ }
53
+ });
54
+
55
+ // You can also combine with other configuration options
56
+ setInitConfig({
57
+ baseURL: 'https://api.custom-domain.com',
58
+ timeout: 10000,
59
+ headers: {
60
+ 'Authorization': 'Bearer your-token',
61
+ 'X-API-Key': 'your-api-key'
62
+ }
63
+ });
64
+ ```
65
+
66
+ **Note**: Custom headers are automatically merged with axios default headers, ensuring both your custom headers and the library's default security headers are included in all requests.
67
+
40
68
  ### Fetch the current checkpoint number
41
69
 
42
70
  ```typescript
@@ -207,43 +235,40 @@ apiClient.tokens.getTokenMetadata(tokenAddress)
207
235
 
208
236
  #### Issue New Token
209
237
  ```typescript
210
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
238
+ import {
239
+ TransactionBuilder,
240
+ createPrivateKeySigner
241
+ } from '@1money/protocol-ts-sdk';
211
242
 
212
243
  // Your private key (DO NOT share or commit your private key)
213
244
  const privateKey = 'YOUR_PRIVATE_KEY';
245
+ const masterAuthority = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
214
246
 
215
- // First, get the latest epoch checkpoint
216
- const epochData = await apiClient.state.getLatestEpochCheckpoint()
247
+ // Get chain id and current nonce
248
+ const { chain_id } = await apiClient.chain.getChainId()
249
+ .success(response => response);
250
+ const { nonce } = await apiClient.accounts.getNonce(masterAuthority)
217
251
  .success(response => response);
218
252
 
219
- // Create the payload array for signing
220
- const payload = [
221
- 1, // chain_id
222
- 1, // nonce
223
- 'MTK', // symbol
224
- 'My Token', // name
225
- 18, // decimals
226
- '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3', // master_authority
227
- true, // is_private
228
- ];
229
-
230
- // Generate signature
231
- const signature = await signMessage(payload, privateKey);
232
- if (!signature) {
233
- throw new Error('Failed to generate signature');
234
- }
235
-
236
- // Create the issue payload
237
- const issuePayload = {
238
- chain_id: 1,
239
- nonce: 1,
240
- name: 'My Token',
253
+ // Build transaction and prepare signature hash internally
254
+ const prepared = TransactionBuilder.tokenIssue({
255
+ chain_id,
256
+ nonce,
241
257
  symbol: 'MTK',
258
+ name: 'My Token',
242
259
  decimals: 18,
243
- master_authority: '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3',
260
+ master_authority: masterAuthority,
244
261
  is_private: true,
245
- signature
246
- };
262
+ clawback_enabled: true
263
+ });
264
+
265
+ // Sign with private key
266
+ const signed = await prepared.sign(
267
+ createPrivateKeySigner(privateKey as `0x${string}`)
268
+ );
269
+
270
+ // Build request body with signature
271
+ const issuePayload = signed.toRequest();
247
272
 
248
273
  apiClient.tokens.issueToken(issuePayload)
249
274
  .success(response => {
@@ -256,40 +281,38 @@ apiClient.tokens.issueToken(issuePayload)
256
281
 
257
282
  #### Manage Token Blacklist/Whitelist
258
283
  ```typescript
259
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
260
- import type { ManageListAction } from '@1money/protocol-ts-sdk/api';
284
+ import {
285
+ ManageListAction,
286
+ TransactionBuilder,
287
+ createPrivateKeySigner
288
+ } from '@1money/protocol-ts-sdk';
261
289
 
262
290
  // Your private key (DO NOT share or commit your private key)
263
291
  const privateKey = 'YOUR_PRIVATE_KEY';
292
+ const operatorAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
264
293
 
265
- // First, get the latest epoch checkpoint
266
- const epochData = await apiClient.state.getLatestEpochCheckpoint()
294
+ // Get chain id and current nonce
295
+ const { chain_id } = await apiClient.chain.getChainId()
296
+ .success(response => response);
297
+ const { nonce } = await apiClient.accounts.getNonce(operatorAddress)
267
298
  .success(response => response);
268
299
 
269
- // Create the payload array for signing
270
- const payload = [
271
- 1, // chain_id
272
- 1, // nonce
273
- ManageListAction.Add, // action
274
- '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3', // address
275
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
276
- ];
300
+ // Build transaction and prepare signature hash internally
301
+ const prepared = TransactionBuilder.tokenManageList({
302
+ chain_id,
303
+ nonce,
304
+ action: ManageListAction.Add,
305
+ address: operatorAddress,
306
+ token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F'
307
+ });
277
308
 
278
- // Generate signature
279
- const signature = await signMessage(payload, privateKey);
280
- if (!signature) {
281
- throw new Error('Failed to generate signature');
282
- }
309
+ // Sign with private key
310
+ const signed = await prepared.sign(
311
+ createPrivateKeySigner(privateKey as `0x${string}`)
312
+ );
283
313
 
284
- // Create the manage list payload
285
- const manageListPayload = {
286
- chain_id: 1,
287
- nonce: 1,
288
- action: ManageListAction.Add,
289
- address: '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3',
290
- token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
291
- signature
292
- };
314
+ // Build request body with signature
315
+ const manageListPayload = signed.toRequest();
293
316
 
294
317
  // Use manageBlacklist for blacklist operations
295
318
  apiClient.tokens.manageBlacklist(manageListPayload)
@@ -312,39 +335,36 @@ apiClient.tokens.manageWhitelist(manageListPayload)
312
335
 
313
336
  #### Burn Tokens
314
337
  ```typescript
315
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
338
+ import {
339
+ TransactionBuilder,
340
+ createPrivateKeySigner
341
+ } from '@1money/protocol-ts-sdk';
316
342
 
317
343
  // Your private key (DO NOT share or commit your private key)
318
344
  const privateKey = 'YOUR_PRIVATE_KEY';
345
+ const ownerAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
319
346
 
320
- // First, get the latest epoch checkpoint
321
- const epochData = await apiClient.state.getLatestEpochCheckpoint()
347
+ // Get chain id and current nonce
348
+ const { chain_id } = await apiClient.chain.getChainId()
349
+ .success(response => response);
350
+ const { nonce } = await apiClient.accounts.getNonce(ownerAddress)
322
351
  .success(response => response);
323
352
 
324
- // Create the payload array for signing
325
- const payload = [
326
- 1, // chain_id
327
- 1, // nonce
328
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // recipient (for burn, same as sender)
329
- '1000000000000000000', // amount
330
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
331
- ];
353
+ // Build transaction and prepare signature hash internally
354
+ const prepared = TransactionBuilder.tokenBurn({
355
+ chain_id,
356
+ nonce,
357
+ value: '1000000000000000000',
358
+ token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F'
359
+ });
332
360
 
333
- // Generate signature
334
- const signature = await signMessage(payload, privateKey);
335
- if (!signature) {
336
- throw new Error('Failed to generate signature');
337
- }
361
+ // Sign with private key
362
+ const signed = await prepared.sign(
363
+ createPrivateKeySigner(privateKey as `0x${string}`)
364
+ );
338
365
 
339
- // Create the burn payload
340
- const burnPayload = {
341
- chain_id: 1,
342
- nonce: 1,
343
- recipient: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
344
- value: '1000000000000000000',
345
- token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
346
- signature
347
- };
366
+ // Build request body with signature
367
+ const burnPayload = signed.toRequest();
348
368
 
349
369
  apiClient.tokens.burnToken(burnPayload)
350
370
  .success(response => {
@@ -357,44 +377,41 @@ apiClient.tokens.burnToken(burnPayload)
357
377
 
358
378
  #### Grant Token Authority
359
379
  ```typescript
360
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
361
- import type { AuthorityType, AuthorityAction } from '@1money/protocol-ts-sdk/api';
380
+ import {
381
+ AuthorityAction,
382
+ AuthorityType,
383
+ TransactionBuilder,
384
+ createPrivateKeySigner
385
+ } from '@1money/protocol-ts-sdk';
362
386
 
363
387
  // Your private key (DO NOT share or commit your private key)
364
388
  const privateKey = 'YOUR_PRIVATE_KEY';
389
+ const masterAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
365
390
 
366
- // First, get the latest epoch checkpoint
367
- const epochData = await apiClient.state.getLatestEpochCheckpoint()
391
+ // Get chain id and current nonce
392
+ const { chain_id } = await apiClient.chain.getChainId()
393
+ .success(response => response);
394
+ const { nonce } = await apiClient.accounts.getNonce(masterAddress)
368
395
  .success(response => response);
369
396
 
370
- // Create the payload array for signing
371
- const payload = [
372
- 1, // chain_id
373
- 1, // nonce
374
- AuthorityAction.Grant, // action
375
- AuthorityType.MasterMint, // authority_type (sends 'MasterMintBurn')
376
- '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3', // authority_address
377
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
378
- '1000000000000000000000', // value (optional, for MintBurnTokens type)
379
- ];
380
-
381
- // Generate signature
382
- const signature = await signMessage(payload, privateKey);
383
- if (!signature) {
384
- throw new Error('Failed to generate signature');
385
- }
386
-
387
- // Create the authority payload
388
- const authorityPayload = {
389
- chain_id: 1,
390
- nonce: 1,
397
+ // Build transaction and prepare signature hash internally
398
+ const prepared = TransactionBuilder.tokenAuthority({
399
+ chain_id,
400
+ nonce,
391
401
  action: AuthorityAction.Grant,
392
- authority_type: AuthorityType.MasterMint, // value is 'MasterMintBurn'
402
+ authority_type: AuthorityType.MasterMint,
393
403
  authority_address: '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3',
394
404
  token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
395
- value: '1000000000000000000000',
396
- signature
397
- };
405
+ value: '1000000000000000000000'
406
+ });
407
+
408
+ // Sign with private key
409
+ const signed = await prepared.sign(
410
+ createPrivateKeySigner(privateKey as `0x${string}`)
411
+ );
412
+
413
+ // Build request body with signature
414
+ const authorityPayload = signed.toRequest();
398
415
 
399
416
  apiClient.tokens.grantAuthority(authorityPayload)
400
417
  .success(response => {
@@ -405,6 +422,100 @@ apiClient.tokens.grantAuthority(authorityPayload)
405
422
  });
406
423
  ```
407
424
 
425
+ #### Bridge and Mint
426
+ ```typescript
427
+ import {
428
+ TransactionBuilder,
429
+ createPrivateKeySigner
430
+ } from '@1money/protocol-ts-sdk';
431
+
432
+ // Your private key (DO NOT share or commit your private key)
433
+ const privateKey = 'YOUR_PRIVATE_KEY';
434
+ const bridgeOperatorAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
435
+
436
+ // Get chain id and current nonce
437
+ const { chain_id } = await apiClient.chain.getChainId()
438
+ .success(response => response);
439
+ const { nonce } = await apiClient.accounts.getNonce(bridgeOperatorAddress)
440
+ .success(response => response);
441
+
442
+ // Build transaction and prepare signature hash internally
443
+ const prepared = TransactionBuilder.tokenBridgeAndMint({
444
+ chain_id,
445
+ nonce,
446
+ recipient: '0x6324dAc598f9B637824978eD6b268C896E0c40E0',
447
+ value: '25000000000000000000',
448
+ token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
449
+ source_chain_id: 1,
450
+ source_tx_hash: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
451
+ bridge_metadata: 'bridge_from_chain_1'
452
+ });
453
+
454
+ // Sign with private key
455
+ const signed = await prepared.sign(
456
+ createPrivateKeySigner(privateKey as `0x${string}`)
457
+ );
458
+
459
+ // Build request body with signature
460
+ const bridgeAndMintPayload = signed.toRequest();
461
+
462
+ apiClient.tokens.bridgeAndMint(bridgeAndMintPayload)
463
+ .success(response => {
464
+ console.log('Bridge and mint transaction hash:', response.hash);
465
+ })
466
+ .error(err => {
467
+ console.error('Error:', err);
468
+ });
469
+ ```
470
+
471
+ #### Burn and Bridge
472
+ ```typescript
473
+ import {
474
+ TransactionBuilder,
475
+ createPrivateKeySigner
476
+ } from '@1money/protocol-ts-sdk';
477
+
478
+ // Your private key (DO NOT share or commit your private key)
479
+ const privateKey = 'YOUR_PRIVATE_KEY';
480
+ const senderAddress = '0x6324dAc598f9B637824978eD6b268C896E0c40E0';
481
+
482
+ // Get chain id and current nonce
483
+ const { chain_id } = await apiClient.chain.getChainId()
484
+ .success(response => response);
485
+ const { nonce } = await apiClient.accounts.getNonce(senderAddress)
486
+ .success(response => response);
487
+
488
+ // Build transaction and prepare signature hash internally
489
+ const prepared = TransactionBuilder.tokenBurnAndBridge({
490
+ chain_id,
491
+ nonce,
492
+ sender: senderAddress,
493
+ value: '20000000000000000000',
494
+ token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
495
+ destination_chain_id: 1,
496
+ destination_address: '0x1234567890abcdef1234567890abcdef12345678',
497
+ escrow_fee: '1000000000000000000',
498
+ bridge_metadata: 'bridge_to_chain_1',
499
+ bridge_param: '0x'
500
+ });
501
+
502
+ // Sign with private key
503
+ const signed = await prepared.sign(
504
+ createPrivateKeySigner(privateKey as `0x${string}`)
505
+ );
506
+
507
+ // Build request body with signature
508
+ const burnAndBridgePayload = signed.toRequest();
509
+
510
+ apiClient.tokens.burnAndBridge(burnAndBridgePayload)
511
+ .success(response => {
512
+ console.log('Burn and bridge transaction hash:', response.hash);
513
+ })
514
+ .error(err => {
515
+ console.error('Error:', err);
516
+ });
517
+ ```
518
+
408
519
  ### Transactions API
409
520
 
410
521
  #### Get Transaction Details
@@ -434,10 +545,11 @@ apiClient.transactions.getReceiptByHash(txHash)
434
545
  #### Estimate Transaction Fee
435
546
  ```typescript
436
547
  const fromAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
548
+ const toAddress = '0x6324dAc598f9B637824978eD6b268C896E0c40E0';
437
549
  const value = '1000000000';
438
550
  const tokenAddress = '0x2cd8999Be299373D7881f4aDD11510030ad1412F';
439
551
 
440
- apiClient.transactions.estimateFee(fromAddress, value, tokenAddress)
552
+ apiClient.transactions.estimateFee(fromAddress, toAddress, value, tokenAddress)
441
553
  .success(response => {
442
554
  console.log('Estimated fee:', response);
443
555
  })
@@ -448,39 +560,37 @@ apiClient.transactions.estimateFee(fromAddress, value, tokenAddress)
448
560
 
449
561
  #### Submit Payment Transaction
450
562
  ```typescript
451
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
563
+ import {
564
+ TransactionBuilder,
565
+ createPrivateKeySigner
566
+ } from '@1money/protocol-ts-sdk';
452
567
 
453
568
  // Your private key (DO NOT share or commit your private key)
454
569
  const privateKey = 'YOUR_PRIVATE_KEY';
570
+ const senderAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
455
571
 
456
- // First, get the latest epoch checkpoint
457
- const epochData = await apiClient.state.getLatestEpochCheckpoint()
572
+ // Get chain id and current nonce
573
+ const { chain_id } = await apiClient.chain.getChainId()
574
+ .success(response => response);
575
+ const { nonce } = await apiClient.accounts.getNonce(senderAddress)
458
576
  .success(response => response);
459
577
 
460
- // Create the payload array for signing
461
- const payload = [
462
- 1, // chain_id
463
- 1, // nonce
464
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // recipient
465
- '1000000000', // value
466
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
467
- ];
578
+ // Build transaction and prepare signature hash internally
579
+ const prepared = TransactionBuilder.payment({
580
+ chain_id,
581
+ nonce,
582
+ recipient: '0xa128999Be299373D7881f4aDD11510030ad13512',
583
+ value: '1000000000',
584
+ token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F'
585
+ });
468
586
 
469
- // Generate signature
470
- const signature = await signMessage(payload, privateKey);
471
- if (!signature) {
472
- throw new Error('Failed to generate signature');
473
- }
587
+ // Sign with private key
588
+ const signed = await prepared.sign(
589
+ createPrivateKeySigner(privateKey as `0x${string}`)
590
+ );
474
591
 
475
- // Create the payment payload
476
- const paymentPayload = {
477
- chain_id: 1,
478
- nonce: 1,
479
- recipient: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
480
- value: '1000000000',
481
- token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
482
- signature
483
- };
592
+ // Build request body with signature
593
+ const paymentPayload = signed.toRequest();
484
594
 
485
595
  apiClient.transactions.payment(paymentPayload)
486
596
  .success(response => {
@@ -1,9 +1,6 @@
1
1
  /**
2
2
  * Integration test helper utilities
3
3
  */
4
- import type { RestSignature } from '../api/tokens/types';
5
- import type { TestAccount } from './setup';
6
- import type { Payload } from '../utils/interface';
7
4
  /**
8
5
  * Create API client for integration tests
9
6
  */
@@ -14,10 +11,6 @@ export declare function createTestClient(): {
14
11
  transactions: typeof import("../api/transactions").transactionsApi;
15
12
  chain: typeof import("../api/chain").chainApi;
16
13
  };
17
- /**
18
- * Sign a payload with an account and return RestSignature format
19
- */
20
- export declare function signPayload(payload: Payload, account: TestAccount): Promise<RestSignature>;
21
14
  /**
22
15
  * Wait for a transaction to be finalized
23
16
  * @param txHash Transaction hash
@@ -12,7 +12,6 @@ export interface Header {
12
12
  receipts_root: B256Schema;
13
13
  number: number;
14
14
  timestamp: number;
15
- extra_data: string;
16
15
  }
17
16
  export interface Checkpoint extends Header {
18
17
  size?: number;
package/es/api/index.js CHANGED
@@ -46,7 +46,7 @@ import'viem';import'@ethereumjs/rlp';import axios from'axios';function _typeof(e
46
46
  this._restScope = scope || this._restScope;
47
47
  // @ts-ignore
48
48
  if (this._restScope.length === 0) {
49
- console.warn('[1Money client]: The ".rest(cb, scope)" scope is empty and will never be triggered!');
49
+ console.warn('[1Money SDK]: The ".rest(cb, scope)" scope is empty and will never be triggered!');
50
50
  }
51
51
  else {
52
52
  let deletedCounter = 0;
@@ -61,7 +61,7 @@ import'viem';import'@ethereumjs/rlp';import axios from'axios';function _typeof(e
61
61
  }
62
62
  });
63
63
  if (deletedCounter === this._restScope.length) {
64
- console.warn(`[1Money client]: The "${this._restScope.join(', ')}" had been called and the "rest" will never be triggered!`);
64
+ console.warn(`[1Money SDK]: The "${this._restScope.join(', ')}" had been called and the "rest" will never be triggered!`);
65
65
  }
66
66
  }
67
67
  return wrapper;
@@ -110,7 +110,7 @@ class Request {
110
110
  }
111
111
  setting(config) {
112
112
  if (!config)
113
- return console.warn('[1Money client]: setting method required correct parameters!');
113
+ return console.warn('[1Money SDK]: setting method required correct parameters!');
114
114
  this._config = { ...this._config, ...config };
115
115
  }
116
116
  request(options) {
@@ -266,7 +266,7 @@ class Request {
266
266
  return;
267
267
  cleanup();
268
268
  const data = err.response?.data ?? {};
269
- console.error(`[1Money client]: Error(${err.status ?? 500}, ${err.code ?? 'UNKNOWN'}), Message: ${err.message}, Config: ${err.config?.method}, ${err.config?.baseURL ?? ''}, ${err.config?.url ?? ''}, ${JSON.stringify(err.config?.headers ?? {})}, Request: ${JSON.stringify(err.config?.data ?? {})}, Response: ${JSON.stringify(data)};`);
269
+ console.error(`[1Money SDK]: Error(${err.status ?? 500}, ${err.code ?? 'UNKNOWN'}), Message: ${err.message}, Config: ${err.config?.method}, ${err.config?.baseURL ?? ''}, ${err.config?.url ?? ''}, ${JSON.stringify(err.config?.headers ?? {})}, Request: ${JSON.stringify(err.config?.data ?? {})}, Response: ${JSON.stringify(data)};`);
270
270
  const status = err.response?.status ?? 500;
271
271
  const headers = err.response?.headers ?? {};
272
272
  try {
@@ -487,6 +487,14 @@ const tokensApi = {
487
487
  */
488
488
  burnAndBridge: (payload) => {
489
489
  return post(`${API_PREFIX$2}/burn_and_bridge`, payload, { withCredentials: false });
490
+ },
491
+ /**
492
+ * Claw back tokens from a wallet
493
+ * @param payload Token clawback request payload
494
+ * @returns Promise with transaction hash response
495
+ */
496
+ clawbackToken: (payload) => {
497
+ return post(`${API_PREFIX$2}/clawback`, payload, { withCredentials: false });
490
498
  }
491
499
  };const API_PREFIX$1 = `/${API_VERSION}/transactions`;
492
500
  /**
@@ -520,15 +528,13 @@ const transactionsApi = {
520
528
  /**
521
529
  * Estimate transaction fee
522
530
  * @param from Address of the transaction author
531
+ * @param to Address of the transaction recipient
523
532
  * @param value Value of the transaction
524
- * @param token Optional token address
533
+ * @param token Token address
525
534
  * @returns Promise with fee estimate response
526
535
  */
527
- estimateFee: (from, value, token) => {
528
- let url = `${API_PREFIX$1}/estimate_fee?from=${from}&value=${value}`;
529
- if (token) {
530
- url += `&token=${token}`;
531
- }
536
+ estimateFee: (from, to, value, token) => {
537
+ const url = `${API_PREFIX$1}/estimate_fee?from=${from}&value=${value}&to=${to}&token=${token}`;
532
538
  return get(url, { withCredentials: false });
533
539
  },
534
540
  /**
@@ -560,6 +566,7 @@ var AuthorityType;
560
566
  AuthorityType["ManageList"] = "ManageList";
561
567
  AuthorityType["UpdateMetadata"] = "UpdateMetadata";
562
568
  AuthorityType["Bridge"] = "Bridge";
569
+ AuthorityType["Clawback"] = "Clawback";
563
570
  })(AuthorityType || (AuthorityType = {}));
564
571
  var AuthorityAction;
565
572
  (function (AuthorityAction) {
@@ -1,5 +1,5 @@
1
1
  import type { Hash, HashWithToken } from '../../api/types';
2
- import type { MintInfo, TokenManageListPayload, TokenBurnPayload, TokenAuthorityPayload, TokenIssuePayload, TokenMintPayload, TokenPausePayload, TokenMetadataPayload, TokenBridgeAndMintPayload, TokenBurnAndBridgePayload } from './types';
2
+ import type { MintInfo, TokenManageListPayload, TokenBurnPayload, TokenAuthorityPayload, TokenIssuePayload, TokenMintPayload, TokenPausePayload, TokenMetadataPayload, TokenBridgeAndMintPayload, TokenBurnAndBridgePayload, TokenClawbackPayload } from './types';
3
3
  /**
4
4
  * Tokens API methods
5
5
  */
@@ -70,5 +70,11 @@ export declare const tokensApi: {
70
70
  * @returns Promise with transaction hash response
71
71
  */
72
72
  burnAndBridge: (payload: TokenBurnAndBridgePayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
73
+ /**
74
+ * Claw back tokens from a wallet
75
+ * @param payload Token clawback request payload
76
+ * @returns Promise with transaction hash response
77
+ */
78
+ clawbackToken: (payload: TokenClawbackPayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
73
79
  };
74
80
  export default tokensApi;