@1money/protocol-ts-sdk 1.1.2 → 2.0.1

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 (69) hide show
  1. package/.claude/settings.local.json +18 -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 +49 -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/core.d.ts +2 -4
  11. package/es/client/index.js +36 -4
  12. package/es/index.d.ts +1 -0
  13. package/es/index.js +513 -22
  14. package/es/signing/builders/index.d.ts +11 -0
  15. package/es/signing/builders/payment.d.ts +3 -0
  16. package/es/signing/builders/tokenAuthority.d.ts +3 -0
  17. package/es/signing/builders/tokenBridgeAndMint.d.ts +3 -0
  18. package/es/signing/builders/tokenBurn.d.ts +3 -0
  19. package/es/signing/builders/tokenBurnAndBridge.d.ts +3 -0
  20. package/es/signing/builders/tokenClawback.d.ts +3 -0
  21. package/es/signing/builders/tokenIssue.d.ts +3 -0
  22. package/es/signing/builders/tokenManageList.d.ts +3 -0
  23. package/es/signing/builders/tokenMetadata.d.ts +3 -0
  24. package/es/signing/builders/tokenMint.d.ts +3 -0
  25. package/es/signing/builders/tokenPause.d.ts +3 -0
  26. package/es/signing/builders/validate.d.ts +18 -0
  27. package/es/signing/core.d.ts +27 -0
  28. package/es/signing/index.d.ts +18 -0
  29. package/es/signing/signer.d.ts +3 -0
  30. package/es/utils/encode.d.ts +11 -0
  31. package/es/utils/index.d.ts +2 -1
  32. package/es/utils/index.js +90 -10
  33. package/es/utils/interface.d.ts +27 -0
  34. package/es/utils/sign.d.ts +6 -1
  35. package/eslint.config.mjs +101 -0
  36. package/lib/__integration__/helpers.d.ts +0 -7
  37. package/lib/api/checkpoints/types.d.ts +0 -1
  38. package/lib/api/index.js +59 -10
  39. package/lib/api/tokens/index.d.ts +7 -1
  40. package/lib/api/tokens/types.d.ts +21 -6
  41. package/lib/api/transactions/index.d.ts +4 -3
  42. package/lib/api/transactions/types.d.ts +14 -5
  43. package/lib/client/core.d.ts +2 -4
  44. package/lib/client/index.js +46 -4
  45. package/lib/index.d.ts +1 -0
  46. package/lib/index.js +511 -21
  47. package/lib/signing/builders/index.d.ts +11 -0
  48. package/lib/signing/builders/payment.d.ts +3 -0
  49. package/lib/signing/builders/tokenAuthority.d.ts +3 -0
  50. package/lib/signing/builders/tokenBridgeAndMint.d.ts +3 -0
  51. package/lib/signing/builders/tokenBurn.d.ts +3 -0
  52. package/lib/signing/builders/tokenBurnAndBridge.d.ts +3 -0
  53. package/lib/signing/builders/tokenClawback.d.ts +3 -0
  54. package/lib/signing/builders/tokenIssue.d.ts +3 -0
  55. package/lib/signing/builders/tokenManageList.d.ts +3 -0
  56. package/lib/signing/builders/tokenMetadata.d.ts +3 -0
  57. package/lib/signing/builders/tokenMint.d.ts +3 -0
  58. package/lib/signing/builders/tokenPause.d.ts +3 -0
  59. package/lib/signing/builders/validate.d.ts +18 -0
  60. package/lib/signing/core.d.ts +27 -0
  61. package/lib/signing/index.d.ts +18 -0
  62. package/lib/signing/signer.d.ts +3 -0
  63. package/lib/utils/encode.d.ts +11 -0
  64. package/lib/utils/index.d.ts +2 -1
  65. package/lib/utils/index.js +90 -10
  66. package/lib/utils/interface.d.ts +27 -0
  67. package/lib/utils/sign.d.ts +6 -1
  68. package/package.json +26 -15
  69. package/umd/1money-protocol-ts-sdk.min.js +4 -2
@@ -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
@@ -1,5 +1,5 @@
1
1
  import { AuthorityType, RestSignature } from '../tokens/types';
2
- import { AddressSchema, B256Schema } from '../types';
2
+ import type { AddressSchema, B256Schema, BytesSchema } from '../types';
3
3
  export interface TransactionReceipt {
4
4
  success: boolean;
5
5
  transaction_hash: B256Schema;
@@ -71,18 +71,24 @@ export interface TokenBridgeAndMintData {
71
71
  value: string;
72
72
  }
73
73
  export interface TokenBurnData {
74
- recipient: AddressSchema;
75
74
  token: AddressSchema;
76
75
  value: string;
77
76
  }
78
77
  export interface TokenBurnAndBridgeData {
79
- bridge_metadata: string | null;
80
- destination_address: AddressSchema;
78
+ value: string;
79
+ sender: AddressSchema;
81
80
  destination_chain_id: number;
81
+ destination_address: AddressSchema;
82
82
  escrow_fee: string;
83
- sender: AddressSchema;
83
+ bridge_metadata: string | null;
84
+ bridge_param: BytesSchema;
84
85
  token: AddressSchema;
86
+ }
87
+ export interface TokenClawbackData {
88
+ from: AddressSchema;
89
+ recipient: AddressSchema;
85
90
  value: string;
91
+ token: AddressSchema;
86
92
  }
87
93
  export interface TokenCloseAccountData {
88
94
  token: AddressSchema;
@@ -152,6 +158,9 @@ export type Transaction = (BaseTransaction & {
152
158
  }) | (BaseTransaction & {
153
159
  transaction_type: 'TokenBurnAndBridge';
154
160
  data: TokenBurnAndBridgeData;
161
+ }) | (BaseTransaction & {
162
+ transaction_type: 'TokenClawback';
163
+ data: TokenClawbackData;
155
164
  }) | (BaseTransaction & {
156
165
  transaction_type: 'TokenCloseAccount';
157
166
  data: TokenCloseAccountData;
@@ -87,22 +87,20 @@ export type ErrorRes = {
87
87
  };
88
88
  export type RestScopeName = ChainName['all'];
89
89
  export type RestScope = Readonly<[RestScopeName, RestScopeName?, RestScopeName?, RestScopeName?, RestScopeName?]>;
90
- type Tuple2Record<T extends readonly any[]> = {
91
- [Value in T[number]]: Value;
92
- };
93
90
  export interface PromiseWrapper<T, U, TSuc = ChainReturn<T, U>['success'], TFail = ChainReturn<T, U>['failure'], TErr = ChainReturn<T, U>['error'], TLogin = ChainReturn<T, U>['login'], TTime = ChainReturn<T, U>['timeout'], HadCall extends string = ''> {
94
91
  success<TRes = TSuc, Delete extends string = HadCall | 'success'>(onSuccess?: (res: ChainReturn<T, U>['success'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TRes, TFail, TErr, TLogin, TTime, Delete>, ChainName['withoutS'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TRes | TFail | TErr | TLogin | TTime>;
95
92
  failure<TRes = TFail, Delete extends string = HadCall | 'failure'>(onFailure?: (res: ChainReturn<T, U>['failure'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TRes, TErr, TLogin, TTime, Delete>, ChainName['withoutF'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TRes | TErr | TLogin | TTime>;
96
93
  error<TRes = TErr, Delete extends string = HadCall | 'error'>(onError?: (err: ChainReturn<T, U>['error'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TRes, TLogin, TTime, Delete>, ChainName['withoutE'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TRes | TLogin | TTime>;
97
94
  login<TRes = TLogin, Delete extends string = HadCall | 'login'>(onLogin?: (res: ChainReturn<T, U>['login'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TRes, TTime, Delete>, ChainName['withoutL'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TErr | TRes | TTime>;
98
95
  timeout<TRes = TTime, Delete extends string = HadCall | 'timeout'>(onTimeout?: (err: ChainReturn<T, U>['timeout'], headers: AxiosReqHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TRes, Delete>, ChainName['withoutT'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TErr | TLogin | TRes>;
99
- rest<TRes = TSuc | TFail | TErr | TLogin | TTime, TRestScope extends RestScope = ['success', 'failure', 'login', 'error', 'timeout'], TRestScopeName extends RestScopeName = Exclude<keyof Tuple2Record<TRestScope>, undefined>, THadCallWithNotInScope extends string = HadCall | Exclude<RestScopeName, TRestScopeName>, Delete extends string = HadCall | TRestScopeName | 'rest'>(onRest?: (val: ChainName['all'] extends THadCallWithNotInScope ? unknown : ChainName['withoutS'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success'] : ChainName['withoutF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure'] : ChainName['withoutE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error'] : ChainName['withoutL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login'] : ChainName['withoutT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['timeout'] : ChainName['withoutSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure'] : ChainName['withoutSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error'] : ChainName['withoutSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login'] : ChainName['withoutST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'timeout'] : ChainName['withoutFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error'] : ChainName['withoutFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login'] : ChainName['withoutFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'timeout'] : ChainName['withoutEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login'] : ChainName['withoutET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'timeout'] : ChainName['withoutLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login' | 'timeout'] : ChainName['withSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login' | 'timeout'] : ChainName['withSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login' | 'timeout'] : ChainName['withSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'timeout'] : ChainName['withST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login'] : ChainName['withFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login' | 'timeout'] : ChainName['withFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'timeout'] : ChainName['withFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login'] : ChainName['withEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'timeout'] : ChainName['withET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login'] : ChainName['withLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error'] : ChainName['success'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login' | 'timeout'] : ChainName['failure'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login' | 'timeout'] : ChainName['error'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login' | 'timeout'] : ChainName['login'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'timeout'] : ChainName['timeout'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'login'] : ChainReturn<T, U>['all'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes, scope?: TRestScope): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TTime, Delete>, Delete> & Promise<ChainName['all'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TTime : ChainName['withoutS'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin | TTime : ChainName['withoutF'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin | TTime : ChainName['withoutE'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin | TTime : ChainName['withoutL'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes | TTime : ChainName['withoutT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TRes : ChainName['withoutSF'] extends THadCallWithNotInScope ? TRes | TErr | TLogin | TTime : ChainName['withoutSE'] extends THadCallWithNotInScope ? TRes | TFail | TLogin | TTime : ChainName['withoutSL'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TTime : ChainName['withoutST'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin : ChainName['withoutFE'] extends THadCallWithNotInScope ? TSuc | TRes | TLogin | TTime : ChainName['withoutFL'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TTime : ChainName['withoutFT'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin : ChainName['withoutEL'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TTime : ChainName['withoutET'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin : ChainName['withoutLT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes : ChainName['withSF'] extends THadCallWithNotInScope ? TSuc | TFail | TRes : ChainName['withSE'] extends THadCallWithNotInScope ? TSuc | TErr | TRes : ChainName['withSL'] extends THadCallWithNotInScope ? TSuc | TLogin | TRes : ChainName['withST'] extends THadCallWithNotInScope ? TSuc | TTime | TRes : ChainName['withFE'] extends THadCallWithNotInScope ? TFail | TErr | TRes : ChainName['withFL'] extends THadCallWithNotInScope ? TFail | TLogin | TRes : ChainName['withFT'] extends THadCallWithNotInScope ? TFail | TTime | TRes : ChainName['withEL'] extends THadCallWithNotInScope ? TErr | TLogin | TRes : ChainName['withET'] extends THadCallWithNotInScope ? TErr | TTime | TRes : ChainName['withLT'] extends THadCallWithNotInScope ? TLogin | TTime | TRes : ChainName['success'] extends THadCallWithNotInScope ? TSuc | TRes : ChainName['failure'] extends THadCallWithNotInScope ? TFail | TRes : ChainName['error'] extends THadCallWithNotInScope ? TErr | TRes : ChainName['login'] extends THadCallWithNotInScope ? TLogin | TRes : ChainName['timeout'] extends THadCallWithNotInScope ? TTime | TRes : TRes>;
96
+ rest<TRes = TSuc | TFail | TErr | TLogin | TTime, S1 extends Exclude<RestScopeName, HadCall> = Exclude<RestScopeName, HadCall>, S2 extends Exclude<RestScopeName, HadCall | S1> | undefined = undefined, S3 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string>> | undefined = undefined, S4 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string> | Extract<S3, string>> | undefined = undefined, S5 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string> | Extract<S3, string> | Extract<S4, string>> | undefined = undefined, TRestScopeName extends RestScopeName = Extract<S1 | S2 | S3 | S4 | S5, RestScopeName>, THadCallWithNotInScope extends string = HadCall | Exclude<RestScopeName, TRestScopeName>, Delete extends string = HadCall | TRestScopeName | 'rest'>(onRest?: (val: ChainName['all'] extends THadCallWithNotInScope ? unknown : ChainName['withoutS'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success'] : ChainName['withoutF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure'] : ChainName['withoutE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error'] : ChainName['withoutL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login'] : ChainName['withoutT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['timeout'] : ChainName['withoutSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure'] : ChainName['withoutSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error'] : ChainName['withoutSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login'] : ChainName['withoutST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'timeout'] : ChainName['withoutFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error'] : ChainName['withoutFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login'] : ChainName['withoutFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'timeout'] : ChainName['withoutEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login'] : ChainName['withoutET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'timeout'] : ChainName['withoutLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login' | 'timeout'] : ChainName['withSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login' | 'timeout'] : ChainName['withSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login' | 'timeout'] : ChainName['withSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'timeout'] : ChainName['withST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login'] : ChainName['withFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login' | 'timeout'] : ChainName['withFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'timeout'] : ChainName['withFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login'] : ChainName['withEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'timeout'] : ChainName['withET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login'] : ChainName['withLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error'] : ChainName['success'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login' | 'timeout'] : ChainName['failure'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login' | 'timeout'] : ChainName['error'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login' | 'timeout'] : ChainName['login'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'timeout'] : ChainName['timeout'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'login'] : ChainReturn<T, U>['all'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes, scope?: Readonly<[S1, S2?, S3?, S4?, S5?]>): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TTime, Delete>, Delete> & Promise<ChainName['all'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TTime : ChainName['withoutS'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin | TTime : ChainName['withoutF'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin | TTime : ChainName['withoutE'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin | TTime : ChainName['withoutL'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes | TTime : ChainName['withoutT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TRes : ChainName['withoutSF'] extends THadCallWithNotInScope ? TRes | TErr | TLogin | TTime : ChainName['withoutSE'] extends THadCallWithNotInScope ? TRes | TFail | TLogin | TTime : ChainName['withoutSL'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TTime : ChainName['withoutST'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin : ChainName['withoutFE'] extends THadCallWithNotInScope ? TSuc | TRes | TLogin | TTime : ChainName['withoutFL'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TTime : ChainName['withoutFT'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin : ChainName['withoutEL'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TTime : ChainName['withoutET'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin : ChainName['withoutLT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes : ChainName['withSF'] extends THadCallWithNotInScope ? TSuc | TFail | TRes : ChainName['withSE'] extends THadCallWithNotInScope ? TSuc | TErr | TRes : ChainName['withSL'] extends THadCallWithNotInScope ? TSuc | TLogin | TRes : ChainName['withST'] extends THadCallWithNotInScope ? TSuc | TTime | TRes : ChainName['withFE'] extends THadCallWithNotInScope ? TFail | TErr | TRes : ChainName['withFL'] extends THadCallWithNotInScope ? TFail | TLogin | TRes : ChainName['withFT'] extends THadCallWithNotInScope ? TFail | TTime | TRes : ChainName['withEL'] extends THadCallWithNotInScope ? TErr | TLogin | TRes : ChainName['withET'] extends THadCallWithNotInScope ? TErr | TTime | TRes : ChainName['withLT'] extends THadCallWithNotInScope ? TLogin | TTime | TRes : ChainName['success'] extends THadCallWithNotInScope ? TSuc | TRes : ChainName['failure'] extends THadCallWithNotInScope ? TFail | TRes : ChainName['error'] extends THadCallWithNotInScope ? TErr | TRes : ChainName['login'] extends THadCallWithNotInScope ? TLogin | TRes : ChainName['timeout'] extends THadCallWithNotInScope ? TTime | TRes : TRes>;
100
97
  }
101
98
  export declare class Request {
102
99
  private _config;
103
100
  axios: AxiosStatic;
104
101
  constructor(config?: InitConfig);
105
102
  private parseError;
103
+ private mergeSignals;
106
104
  setting(config: InitConfig): void;
107
105
  request<T, U = unknown>(options: Options<T, U>): PromiseWrapper<T, U> & Promise<CustomResponseData<T, U, WithFailureData<T>>>;
108
106
  }
@@ -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;
@@ -108,9 +108,26 @@ class Request {
108
108
  data
109
109
  };
110
110
  }
111
+ mergeSignals(...signals) {
112
+ const controller = new AbortController();
113
+ const onAbort = () => controller.abort();
114
+ const cleanups = [];
115
+ for (const signal of signals) {
116
+ if (signal.aborted) {
117
+ controller.abort();
118
+ break;
119
+ }
120
+ signal.addEventListener('abort', onAbort);
121
+ cleanups.push(() => signal.removeEventListener('abort', onAbort));
122
+ }
123
+ return {
124
+ signal: controller.signal,
125
+ cleanup: () => cleanups.forEach(fn => fn()),
126
+ };
127
+ }
111
128
  setting(config) {
112
129
  if (!config)
113
- return console.warn('[1Money client]: setting method required correct parameters!');
130
+ return console.warn('[1Money SDK]: setting method required correct parameters!');
114
131
  this._config = { ...this._config, ...config };
115
132
  }
116
133
  request(options) {
@@ -208,18 +225,33 @@ class Request {
208
225
  let timer = null;
209
226
  let isTimeout = false;
210
227
  const _timeout = timeout ?? initTimeout;
228
+ const controller = new AbortController();
229
+ let signalCleanup = null;
230
+ if (options.signal) {
231
+ const merged = this.mergeSignals(options.signal, controller.signal);
232
+ options.signal = merged.signal;
233
+ signalCleanup = merged.cleanup;
234
+ }
235
+ else {
236
+ options.signal = controller.signal;
237
+ }
211
238
  // Cleanup function for timeout
212
239
  const cleanup = () => {
213
240
  if (timer !== null) {
214
241
  clearTimeout(timer);
215
242
  timer = null;
216
243
  }
244
+ if (signalCleanup) {
245
+ signalCleanup();
246
+ signalCleanup = null;
247
+ }
217
248
  };
218
249
  if (_timeout) {
219
250
  timer = setTimeout(async () => {
220
251
  try {
221
252
  isTimeout = true;
222
253
  cleanup();
254
+ controller.abort();
223
255
  let err = this.parseError('timeout');
224
256
  // @ts-ignore
225
257
  const res = await Promise.resolve(callbacks.timeout(err, options.headers ?? {}));
@@ -266,7 +298,7 @@ class Request {
266
298
  return;
267
299
  cleanup();
268
300
  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)};`);
301
+ 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
302
  const status = err.response?.status ?? 500;
271
303
  const headers = err.response?.headers ?? {};
272
304
  try {
package/es/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { api } from './api/index.js';
2
2
  export { api } from './api/index.js';
3
3
  export { default as client } from './client/index.js';
4
+ export * from './signing';
4
5
  export * from './utils/index.js';
5
6
  export type { AxiosStatic } from 'axios';
6
7
  export type { InitConfig, Options, ParsedError, PromiseWrapper } from './client/core';