@1money/protocol-ts-sdk 1.1.2 → 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 (66) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/README.md +216 -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
@@ -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
@@ -235,43 +235,40 @@ apiClient.tokens.getTokenMetadata(tokenAddress)
235
235
 
236
236
  #### Issue New Token
237
237
  ```typescript
238
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
238
+ import {
239
+ TransactionBuilder,
240
+ createPrivateKeySigner
241
+ } from '@1money/protocol-ts-sdk';
239
242
 
240
243
  // Your private key (DO NOT share or commit your private key)
241
244
  const privateKey = 'YOUR_PRIVATE_KEY';
245
+ const masterAuthority = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
242
246
 
243
- // First, get the latest epoch checkpoint
244
- 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)
245
251
  .success(response => response);
246
252
 
247
- // Create the payload array for signing
248
- const payload = [
249
- 1, // chain_id
250
- 1, // nonce
251
- 'MTK', // symbol
252
- 'My Token', // name
253
- 18, // decimals
254
- '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3', // master_authority
255
- true, // is_private
256
- ];
257
-
258
- // Generate signature
259
- const signature = await signMessage(payload, privateKey);
260
- if (!signature) {
261
- throw new Error('Failed to generate signature');
262
- }
263
-
264
- // Create the issue payload
265
- const issuePayload = {
266
- chain_id: 1,
267
- nonce: 1,
268
- name: 'My Token',
253
+ // Build transaction and prepare signature hash internally
254
+ const prepared = TransactionBuilder.tokenIssue({
255
+ chain_id,
256
+ nonce,
269
257
  symbol: 'MTK',
258
+ name: 'My Token',
270
259
  decimals: 18,
271
- master_authority: '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3',
260
+ master_authority: masterAuthority,
272
261
  is_private: true,
273
- signature
274
- };
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();
275
272
 
276
273
  apiClient.tokens.issueToken(issuePayload)
277
274
  .success(response => {
@@ -284,40 +281,38 @@ apiClient.tokens.issueToken(issuePayload)
284
281
 
285
282
  #### Manage Token Blacklist/Whitelist
286
283
  ```typescript
287
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
288
- import type { ManageListAction } from '@1money/protocol-ts-sdk/api';
284
+ import {
285
+ ManageListAction,
286
+ TransactionBuilder,
287
+ createPrivateKeySigner
288
+ } from '@1money/protocol-ts-sdk';
289
289
 
290
290
  // Your private key (DO NOT share or commit your private key)
291
291
  const privateKey = 'YOUR_PRIVATE_KEY';
292
+ const operatorAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
292
293
 
293
- // First, get the latest epoch checkpoint
294
- 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)
295
298
  .success(response => response);
296
299
 
297
- // Create the payload array for signing
298
- const payload = [
299
- 1, // chain_id
300
- 1, // nonce
301
- ManageListAction.Add, // action
302
- '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3', // address
303
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
304
- ];
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
+ });
305
308
 
306
- // Generate signature
307
- const signature = await signMessage(payload, privateKey);
308
- if (!signature) {
309
- throw new Error('Failed to generate signature');
310
- }
309
+ // Sign with private key
310
+ const signed = await prepared.sign(
311
+ createPrivateKeySigner(privateKey as `0x${string}`)
312
+ );
311
313
 
312
- // Create the manage list payload
313
- const manageListPayload = {
314
- chain_id: 1,
315
- nonce: 1,
316
- action: ManageListAction.Add,
317
- address: '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3',
318
- token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
319
- signature
320
- };
314
+ // Build request body with signature
315
+ const manageListPayload = signed.toRequest();
321
316
 
322
317
  // Use manageBlacklist for blacklist operations
323
318
  apiClient.tokens.manageBlacklist(manageListPayload)
@@ -340,39 +335,36 @@ apiClient.tokens.manageWhitelist(manageListPayload)
340
335
 
341
336
  #### Burn Tokens
342
337
  ```typescript
343
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
338
+ import {
339
+ TransactionBuilder,
340
+ createPrivateKeySigner
341
+ } from '@1money/protocol-ts-sdk';
344
342
 
345
343
  // Your private key (DO NOT share or commit your private key)
346
344
  const privateKey = 'YOUR_PRIVATE_KEY';
345
+ const ownerAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
347
346
 
348
- // First, get the latest epoch checkpoint
349
- 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)
350
351
  .success(response => response);
351
352
 
352
- // Create the payload array for signing
353
- const payload = [
354
- 1, // chain_id
355
- 1, // nonce
356
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // recipient (for burn, same as sender)
357
- '1000000000000000000', // amount
358
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
359
- ];
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
+ });
360
360
 
361
- // Generate signature
362
- const signature = await signMessage(payload, privateKey);
363
- if (!signature) {
364
- throw new Error('Failed to generate signature');
365
- }
361
+ // Sign with private key
362
+ const signed = await prepared.sign(
363
+ createPrivateKeySigner(privateKey as `0x${string}`)
364
+ );
366
365
 
367
- // Create the burn payload
368
- const burnPayload = {
369
- chain_id: 1,
370
- nonce: 1,
371
- recipient: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
372
- value: '1000000000000000000',
373
- token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
374
- signature
375
- };
366
+ // Build request body with signature
367
+ const burnPayload = signed.toRequest();
376
368
 
377
369
  apiClient.tokens.burnToken(burnPayload)
378
370
  .success(response => {
@@ -385,44 +377,41 @@ apiClient.tokens.burnToken(burnPayload)
385
377
 
386
378
  #### Grant Token Authority
387
379
  ```typescript
388
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
389
- 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';
390
386
 
391
387
  // Your private key (DO NOT share or commit your private key)
392
388
  const privateKey = 'YOUR_PRIVATE_KEY';
389
+ const masterAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
393
390
 
394
- // First, get the latest epoch checkpoint
395
- 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)
396
395
  .success(response => response);
397
396
 
398
- // Create the payload array for signing
399
- const payload = [
400
- 1, // chain_id
401
- 1, // nonce
402
- AuthorityAction.Grant, // action
403
- AuthorityType.MasterMint, // authority_type (sends 'MasterMintBurn')
404
- '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3', // authority_address
405
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
406
- '1000000000000000000000', // value (optional, for MintBurnTokens type)
407
- ];
408
-
409
- // Generate signature
410
- const signature = await signMessage(payload, privateKey);
411
- if (!signature) {
412
- throw new Error('Failed to generate signature');
413
- }
414
-
415
- // Create the authority payload
416
- const authorityPayload = {
417
- chain_id: 1,
418
- nonce: 1,
397
+ // Build transaction and prepare signature hash internally
398
+ const prepared = TransactionBuilder.tokenAuthority({
399
+ chain_id,
400
+ nonce,
419
401
  action: AuthorityAction.Grant,
420
- authority_type: AuthorityType.MasterMint, // value is 'MasterMintBurn'
402
+ authority_type: AuthorityType.MasterMint,
421
403
  authority_address: '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3',
422
404
  token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
423
- value: '1000000000000000000000',
424
- signature
425
- };
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();
426
415
 
427
416
  apiClient.tokens.grantAuthority(authorityPayload)
428
417
  .success(response => {
@@ -433,6 +422,100 @@ apiClient.tokens.grantAuthority(authorityPayload)
433
422
  });
434
423
  ```
435
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
+
436
519
  ### Transactions API
437
520
 
438
521
  #### Get Transaction Details
@@ -462,10 +545,11 @@ apiClient.transactions.getReceiptByHash(txHash)
462
545
  #### Estimate Transaction Fee
463
546
  ```typescript
464
547
  const fromAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
548
+ const toAddress = '0x6324dAc598f9B637824978eD6b268C896E0c40E0';
465
549
  const value = '1000000000';
466
550
  const tokenAddress = '0x2cd8999Be299373D7881f4aDD11510030ad1412F';
467
551
 
468
- apiClient.transactions.estimateFee(fromAddress, value, tokenAddress)
552
+ apiClient.transactions.estimateFee(fromAddress, toAddress, value, tokenAddress)
469
553
  .success(response => {
470
554
  console.log('Estimated fee:', response);
471
555
  })
@@ -476,39 +560,37 @@ apiClient.transactions.estimateFee(fromAddress, value, tokenAddress)
476
560
 
477
561
  #### Submit Payment Transaction
478
562
  ```typescript
479
- import { signMessage, toHex } from '@1money/protocol-ts-sdk';
563
+ import {
564
+ TransactionBuilder,
565
+ createPrivateKeySigner
566
+ } from '@1money/protocol-ts-sdk';
480
567
 
481
568
  // Your private key (DO NOT share or commit your private key)
482
569
  const privateKey = 'YOUR_PRIVATE_KEY';
570
+ const senderAddress = '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3';
483
571
 
484
- // First, get the latest epoch checkpoint
485
- 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)
486
576
  .success(response => response);
487
577
 
488
- // Create the payload array for signing
489
- const payload = [
490
- 1, // chain_id
491
- 1, // nonce
492
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // recipient
493
- '1000000000', // value
494
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
495
- ];
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
+ });
496
586
 
497
- // Generate signature
498
- const signature = await signMessage(payload, privateKey);
499
- if (!signature) {
500
- throw new Error('Failed to generate signature');
501
- }
587
+ // Sign with private key
588
+ const signed = await prepared.sign(
589
+ createPrivateKeySigner(privateKey as `0x${string}`)
590
+ );
502
591
 
503
- // Create the payment payload
504
- const paymentPayload = {
505
- chain_id: 1,
506
- nonce: 1,
507
- recipient: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
508
- value: '1000000000',
509
- token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
510
- signature
511
- };
592
+ // Build request body with signature
593
+ const paymentPayload = signed.toRequest();
512
594
 
513
595
  apiClient.transactions.payment(paymentPayload)
514
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;
@@ -1,4 +1,4 @@
1
- import { AddressSchema, U256Schema } from '../types';
1
+ import type { AddressSchema, BytesSchema, U256Schema } from '../types';
2
2
  import type { Signature } from '../../utils/index.js';
3
3
  export interface MetaDataKeyValuePair {
4
4
  key: string;
@@ -28,6 +28,7 @@ export interface MintInfo {
28
28
  decimals: number;
29
29
  is_paused: boolean;
30
30
  is_private: boolean;
31
+ clawback_enabled: boolean;
31
32
  meta: TokenMetadata;
32
33
  }
33
34
  export interface KeyValuePair {
@@ -40,7 +41,8 @@ export declare enum AuthorityType {
40
41
  Pause = "Pause",
41
42
  ManageList = "ManageList",
42
43
  UpdateMetadata = "UpdateMetadata",
43
- Bridge = "Bridge"
44
+ Bridge = "Bridge",
45
+ Clawback = "Clawback"
44
46
  }
45
47
  export declare enum AuthorityAction {
46
48
  Grant = "Grant",
@@ -67,7 +69,6 @@ export interface TokenManageListPayload {
67
69
  export interface TokenBurnPayload {
68
70
  chain_id: number;
69
71
  nonce: number;
70
- recipient: string;
71
72
  value: string;
72
73
  token: string;
73
74
  signature: RestSignature;
@@ -90,6 +91,10 @@ export interface TokenIssuePayload {
90
91
  decimals: number;
91
92
  master_authority: string;
92
93
  is_private: boolean;
94
+ /**
95
+ * @default true
96
+ */
97
+ clawback_enabled?: boolean;
93
98
  signature: RestSignature;
94
99
  }
95
100
  export interface TokenMintPayload {
@@ -128,14 +133,24 @@ export interface TokenBridgeAndMintPayload {
128
133
  signature: RestSignature;
129
134
  }
130
135
  export interface TokenBurnAndBridgePayload {
131
- bridge_metadata: string;
132
136
  chain_id: number;
133
- destination_address: string;
137
+ nonce: number;
138
+ sender: string;
139
+ value: string;
140
+ token: string;
134
141
  destination_chain_id: number;
142
+ destination_address: string;
135
143
  escrow_fee: string;
144
+ bridge_metadata: string;
145
+ bridge_param: BytesSchema;
146
+ signature: RestSignature;
147
+ }
148
+ export interface TokenClawbackPayload {
149
+ chain_id: number;
136
150
  nonce: number;
137
- sender: string;
138
151
  token: string;
152
+ from: string;
153
+ recipient: string;
139
154
  value: string;
140
155
  signature: RestSignature;
141
156
  }
@@ -1,5 +1,5 @@
1
1
  import type { Hash } from '../../api/types';
2
- import type { EstimateFee, PaymentPayload, Transaction, TransactionReceipt, FinalizedTransactionReceipt } from './types';
2
+ import type { EstimateFee, FinalizedTransactionReceipt, PaymentPayload, Transaction, TransactionReceipt } from './types';
3
3
  /**
4
4
  * Transactions API methods
5
5
  */
@@ -25,11 +25,12 @@ export declare const transactionsApi: {
25
25
  /**
26
26
  * Estimate transaction fee
27
27
  * @param from Address of the transaction author
28
+ * @param to Address of the transaction recipient
28
29
  * @param value Value of the transaction
29
- * @param token Optional token address
30
+ * @param token Token address
30
31
  * @returns Promise with fee estimate response
31
32
  */
32
- estimateFee: (from: string, value: string, token?: string) => import("../../client/index.js").PromiseWrapper<"custom", EstimateFee, EstimateFee, EstimateFee, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | EstimateFee, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<EstimateFee>;
33
+ estimateFee: (from: string, to: string, value: string, token: string) => import("../../client/index.js").PromiseWrapper<"custom", EstimateFee, EstimateFee, EstimateFee, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | EstimateFee, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<EstimateFee>;
33
34
  /**
34
35
  * Submit payment transaction
35
36
  * @param payload Payment transaction payload