@bloque/sdk-swap 0.0.33 → 0.0.34

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.
@@ -0,0 +1,53 @@
1
+ import { BaseClient } from '@bloque/sdk-core';
2
+ import type { CreateBankTransferOrderParams, CreateBankTransferOrderResult } from './types';
3
+ /**
4
+ * Generic bank transfer client for cash-out swaps
5
+ *
6
+ * Supports any Colombian bank as the destination medium.
7
+ * The specific bank is selected via the `toMedium` parameter when creating an order.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const result = await bloque.swap.bankTransfer.create({
12
+ * rateSig: rate.sig,
13
+ * toMedium: 'banco_de_bogota',
14
+ * amountSrc: '5000000',
15
+ * depositInformation: {
16
+ * bankAccountType: 'savings',
17
+ * bankAccountNumber: '123456789',
18
+ * bankAccountHolderName: 'Juan Pérez',
19
+ * bankAccountHolderIdentificationType: 'CC',
20
+ * bankAccountHolderIdentificationValue: '1234567890',
21
+ * },
22
+ * args: { accountUrn: 'did:bloque:card:abc123' },
23
+ * });
24
+ * ```
25
+ */
26
+ export declare class BankTransferClient extends BaseClient {
27
+ /**
28
+ * Create a bank transfer swap order
29
+ *
30
+ * Creates a swap order using Kusama as the source and any supported
31
+ * Colombian bank as the destination. The target bank is specified
32
+ * via `params.toMedium`.
33
+ *
34
+ * @param params - Bank transfer order parameters
35
+ * @returns Promise resolving to the created order with optional execution result
36
+ */
37
+ create(params: CreateBankTransferOrderParams): Promise<CreateBankTransferOrderResult>;
38
+ /**
39
+ * Maps SDK deposit information to wire format
40
+ * @internal
41
+ */
42
+ private _mapDepositInformationToWire;
43
+ /**
44
+ * Maps API order response to SDK format
45
+ * @internal
46
+ */
47
+ private _mapOrderResponse;
48
+ /**
49
+ * Maps API execution result to SDK format
50
+ * @internal
51
+ */
52
+ private _mapExecutionResult;
53
+ }
@@ -0,0 +1,242 @@
1
+ /**
2
+ * Generic bank transfer types for @bloque/sdk-swap
3
+ *
4
+ * Supports any Colombian bank as the destination medium for cash-out swaps.
5
+ */
6
+ /**
7
+ * Supported Colombian banks for cash-out transfers
8
+ *
9
+ * @example Transfer to Bancolombia
10
+ * ```typescript
11
+ * await bloque.swap.bankTransfer.create({
12
+ * rateSig: rate.sig,
13
+ * toMedium: 'bancolombia',
14
+ * amountSrc: '5000000',
15
+ * depositInformation: {
16
+ * bankAccountType: 'savings',
17
+ * bankAccountNumber: '5740088718',
18
+ * bankAccountHolderName: 'Juan Pérez',
19
+ * bankAccountHolderIdentificationType: 'CC',
20
+ * bankAccountHolderIdentificationValue: '1234567890',
21
+ * },
22
+ * args: { sourceAccountUrn: 'did:bloque:card:abc123' },
23
+ * });
24
+ * ```
25
+ *
26
+ * @example Transfer to Banco de Bogotá
27
+ * ```typescript
28
+ * await bloque.swap.bankTransfer.create({
29
+ * rateSig: rate.sig,
30
+ * toMedium: 'banco_de_bogota',
31
+ * amountSrc: '2000000',
32
+ * depositInformation: {
33
+ * bankAccountType: 'checking',
34
+ * bankAccountNumber: '987654321',
35
+ * bankAccountHolderName: 'María López',
36
+ * bankAccountHolderIdentificationType: 'CE',
37
+ * bankAccountHolderIdentificationValue: '456789',
38
+ * },
39
+ * args: { sourceAccountUrn: 'did:bloque:card:xyz789' },
40
+ * });
41
+ * ```
42
+ *
43
+ * @example Transfer to BBVA Colombia
44
+ * ```typescript
45
+ * await bloque.swap.bankTransfer.create({
46
+ * rateSig: rate.sig,
47
+ * toMedium: 'banco_bbva_colombia',
48
+ * amountSrc: '10000000',
49
+ * depositInformation: {
50
+ * bankAccountType: 'savings',
51
+ * bankAccountNumber: '1122334455',
52
+ * bankAccountHolderName: 'Carlos Ruiz',
53
+ * bankAccountHolderIdentificationType: 'NIT',
54
+ * bankAccountHolderIdentificationValue: '900123456',
55
+ * },
56
+ * args: { sourceAccountUrn: 'did:bloque:card:def456' },
57
+ * });
58
+ * ```
59
+ */
60
+ export type SupportedBank = 'banco_agrario_de_colombia' | 'banco_av_villas' | 'banco_bancamia' | 'banco_bbva_colombia' | 'banco_btg_pactual_colombia' | 'citibank_colombia' | 'banco_caja_social_bcsc' | 'davibank' | 'banco_contactar' | 'banco_cooperativo_coopcentral' | 'ban100' | 'banco_davivienda' | 'banco_de_bogota' | 'banco_de_occidente' | 'banco_gnb_sudameris' | 'banco_jp_morgan_colombia' | 'banco_popular' | 'banco_itau' | 'bancolombia' | 'banco_w' | 'banco_coomeva' | 'banco_finandina_bic' | 'banco_falabella' | 'banco_pichincha' | 'banco_santander_de_negocios_colombia' | 'banco_mundo_mujer' | 'banco_serfinanza' | 'mibanco' | 'lulo_bank' | 'banco_union';
61
+ /**
62
+ * Bank account type
63
+ */
64
+ export type BankAccountType = 'savings' | 'checking';
65
+ /**
66
+ * Identification type for account holder
67
+ */
68
+ export type IdentificationType = 'CC' | 'CE' | 'NIT' | 'PP';
69
+ /**
70
+ * Bank deposit information for direct bank transfers
71
+ *
72
+ * This is the same shape for all Colombian banks — the specific bank
73
+ * is selected via the `toMedium` parameter in the order.
74
+ */
75
+ export interface BankDepositInformation {
76
+ /**
77
+ * Bank account type
78
+ * @example "savings"
79
+ */
80
+ bankAccountType: BankAccountType;
81
+ /**
82
+ * Bank account number
83
+ * @example "5740088718"
84
+ */
85
+ bankAccountNumber: string;
86
+ /**
87
+ * Account holder full name
88
+ * @example "david barinas"
89
+ */
90
+ bankAccountHolderName: string;
91
+ /**
92
+ * Account holder identification type
93
+ * @example "CC"
94
+ */
95
+ bankAccountHolderIdentificationType: IdentificationType;
96
+ /**
97
+ * Account holder identification number
98
+ * @example "123456789"
99
+ */
100
+ bankAccountHolderIdentificationValue: string;
101
+ }
102
+ /**
103
+ * Kusama account arguments for swap execution
104
+ */
105
+ export interface KusamaAccountArgs {
106
+ /**
107
+ * Account URN where funds will be debited from
108
+ * @example "did:bloque:card:1231231"
109
+ */
110
+ sourceAccountUrn: string;
111
+ }
112
+ /**
113
+ * Order type for swap
114
+ * - 'src': Taker specifies exact source amount to pay
115
+ * - 'dst': Taker specifies exact destination amount to receive
116
+ */
117
+ export type OrderType = 'src' | 'dst';
118
+ /**
119
+ * Parameters for creating a bank transfer swap order
120
+ */
121
+ export interface CreateBankTransferOrderParams {
122
+ /**
123
+ * Rate signature from findRates
124
+ */
125
+ rateSig: string;
126
+ /**
127
+ * Destination bank medium (e.g., "bancolombia", "banco_de_bogota", "banco_davivienda")
128
+ * @example "banco_bbva_colombia"
129
+ */
130
+ toMedium: SupportedBank;
131
+ /**
132
+ * Source amount as bigint string (required if type is 'src')
133
+ * @example "100000000"
134
+ */
135
+ amountSrc?: string;
136
+ /**
137
+ * Destination amount as bigint string (required if type is 'dst')
138
+ * @example "50000000" represents 500000.00 COP
139
+ */
140
+ amountDst?: string;
141
+ /**
142
+ * Order type (default: 'src')
143
+ */
144
+ type?: OrderType;
145
+ /**
146
+ * Bank account information for fund delivery
147
+ */
148
+ depositInformation: BankDepositInformation;
149
+ /**
150
+ * Kusama account arguments for swap execution
151
+ */
152
+ args: KusamaAccountArgs;
153
+ /**
154
+ * Specific node ID to execute (defaults to first node)
155
+ */
156
+ nodeId?: string;
157
+ /**
158
+ * Additional metadata for the order
159
+ */
160
+ metadata?: Record<string, unknown>;
161
+ }
162
+ /**
163
+ * Swap order details
164
+ */
165
+ export interface SwapOrder {
166
+ /** Unique order identifier */
167
+ id: string;
168
+ /** Order signature */
169
+ orderSig: string;
170
+ /** Rate signature used for this order */
171
+ rateSig: string;
172
+ /** Swap signature */
173
+ swapSig: string;
174
+ /** Taker URN */
175
+ taker: string;
176
+ /** Maker URN */
177
+ maker: string;
178
+ /** Source asset */
179
+ fromAsset: string;
180
+ /** Destination asset */
181
+ toAsset: string;
182
+ /** Source medium */
183
+ fromMedium: string;
184
+ /** Destination medium (bank name) */
185
+ toMedium: string;
186
+ /** Source amount */
187
+ fromAmount: string;
188
+ /** Destination amount */
189
+ toAmount: string;
190
+ /** Timestamp when the order was created */
191
+ at: string;
192
+ /** Instruction graph ID for tracking execution */
193
+ graphId: string;
194
+ /** Order status */
195
+ status: string;
196
+ /** Additional metadata */
197
+ metadata?: Record<string, unknown>;
198
+ /** Creation timestamp */
199
+ createdAt: string;
200
+ /** Last update timestamp */
201
+ updatedAt: string;
202
+ }
203
+ /**
204
+ * Redirect instructions for completing the payment
205
+ */
206
+ export interface ExecutionHow {
207
+ /** Type of action required (e.g., "REDIRECT") */
208
+ type: string;
209
+ /** URL to redirect the user to complete the payment */
210
+ url: string;
211
+ }
212
+ /**
213
+ * Execution result from auto-execution
214
+ */
215
+ export interface ExecutionResult {
216
+ /** Node ID that was executed */
217
+ nodeId: string;
218
+ /** Execution result details */
219
+ result: {
220
+ /** Execution status (e.g., "paused") */
221
+ status: string;
222
+ /** Name of the current step */
223
+ name?: string;
224
+ /** Description of what the user needs to do */
225
+ description?: string;
226
+ /** Instructions for completing this step */
227
+ how?: ExecutionHow;
228
+ /** Callback token for tracking */
229
+ callbackToken?: string;
230
+ };
231
+ }
232
+ /**
233
+ * Result of creating a bank transfer swap order
234
+ */
235
+ export interface CreateBankTransferOrderResult {
236
+ /** The created order */
237
+ order: SwapOrder;
238
+ /** Execution result (if args were provided for auto-execution) */
239
+ execution?: ExecutionResult;
240
+ /** Request ID for tracking */
241
+ requestId: string;
242
+ }
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{PseClient:()=>PseClient,SwapClient:()=>SwapClient,BancolombiaClient:()=>BancolombiaClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t=this.httpClient.urn;if(!t)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",r={taker_urn:t,type:a,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"bancolombia",deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(r.amount_dst=e.amountDst),e.args&&(r.args={account_urn:e.args.accountUrn}),e.nodeId&&(r.node_id=e.nodeId),e.metadata&&(r.metadata=e.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:r});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapDepositInformationToWire(e){return{bank_account_type:e.bankAccountType,bank_account_number:e.bankAccountNumber,bank_account_holder_name:e.bankAccountHolderName,bank_account_holder_identification_type:e.bankAccountHolderIdentificationType,bank_account_holder_identification_value:e.bankAccountHolderIdentificationValue}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how,callbackToken:e.result.callback_token}}}}class PseClient extends sdk_core_namespaceObject.BaseClient{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(e=>this._mapBankResponse(e))}}async create(e){let t=this.httpClient.urn;if(!t)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",r={taker_urn:t,type:a,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(r.amount_dst=e.amountDst),e.args&&(r.args={bank_code:e.args.bankCode,...e.args.userType&&{user_type:e.args.userType},...e.args.customerEmail&&{customer_email:e.args.customerEmail},...e.args.userLegalIdType&&{user_legal_id_type:e.args.userLegalIdType},...e.args.userLegalId&&{user_legal_id:e.args.userLegalId},...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(r.node_id=e.nodeId),e.metadata&&(r.metadata=e.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:r});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapBankResponse(e){return{code:e.financial_institution_code,name:e.financial_institution_name}}_mapDepositInformationToWire(e){return{urn:e.urn}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how,callbackToken:e.result.callback_token}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;bancolombia;constructor(e){super(e),this.pse=new PseClient(this.httpClient),this.bancolombia=new BancolombiaClient(this.httpClient)}async findRates(e){let t=new URLSearchParams,a=JSON.stringify([e.fromAsset,e.toAsset]);t.append("edge",a),t.append("from_medium",JSON.stringify(e.fromMediums)),t.append("to_medium",JSON.stringify(e.toMediums)),void 0!==e.amountSrc&&t.append("amount_src",e.amountSrc),void 0!==e.amountDst&&t.append("amount_dst",e.amountDst),e.sort&&t.append("sort",e.sort),e.sortBy&&t.append("sort_by",e.sortBy);let r=t.toString(),o=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:o})).rates.map(e=>this._mapRateResponse(e))}}_mapRateResponse(e){return{id:e.id,sig:e.sig,swapSig:e.swap_sig,maker:e.maker,edge:e.edge,fee:{at:e.fee.at,value:e.fee.value,formula:e.fee.formula,components:e.fee.components.map(e=>({at:e.at,name:e.name,type:e.type,value:e.value,percentage:e.percentage,pair:e.pair,amount:e.amount}))},at:e.at,until:e.until,fromMediums:e.from_medium,toMediums:e.to_medium,rate:e.rate,ratio:e.ratio,fromLimits:e.from_limits,toLimits:e.to_limits,createdAt:e.created_at,updatedAt:e.updated_at}}}for(var __rspack_i in exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.PseClient=__webpack_exports__.PseClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["BancolombiaClient","PseClient","SwapClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{SwapClient:()=>SwapClient,BankTransferClient:()=>BankTransferClient,PseClient:()=>PseClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BankTransferClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t=this.httpClient.urn;if(!t)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",r={taker_urn:t,type:a,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(r.amount_dst=e.amountDst),e.args&&(r.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(r.node_id=e.nodeId),e.metadata&&(r.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:r});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapDepositInformationToWire(e){return{bank_account_type:e.bankAccountType,bank_account_number:e.bankAccountNumber,bank_account_holder_name:e.bankAccountHolderName,bank_account_holder_identification_type:e.bankAccountHolderIdentificationType,bank_account_holder_identification_value:e.bankAccountHolderIdentificationValue}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how,callbackToken:e.result.callback_token}}}}class PseClient extends sdk_core_namespaceObject.BaseClient{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(e=>this._mapBankResponse(e))}}async create(e){let t=this.httpClient.urn;if(!t)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",r={taker_urn:t,type:a,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(r.amount_dst=e.amountDst),e.args&&(r.args={bank_code:e.args.bankCode,...e.args.userType&&{user_type:e.args.userType},...e.args.customerEmail&&{customer_email:e.args.customerEmail},...e.args.userLegalIdType&&{user_legal_id_type:e.args.userLegalIdType},...e.args.userLegalId&&{user_legal_id:e.args.userLegalId},...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(r.node_id=e.nodeId),e.metadata&&(r.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:r});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapBankResponse(e){return{code:e.financial_institution_code,name:e.financial_institution_name}}_mapDepositInformationToWire(e){return{urn:e.urn}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how,callbackToken:e.result.callback_token}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;bankTransfer;constructor(e){super(e),this.pse=new PseClient(this.httpClient),this.bankTransfer=new BankTransferClient(this.httpClient)}async findRates(e){let t=new URLSearchParams,a=JSON.stringify([e.fromAsset,e.toAsset]);t.append("edge",a),t.append("from_medium",JSON.stringify(e.fromMediums)),t.append("to_medium",JSON.stringify(e.toMediums)),void 0!==e.amountSrc&&t.append("amount_src",e.amountSrc),void 0!==e.amountDst&&t.append("amount_dst",e.amountDst),e.sort&&t.append("sort",e.sort),e.sortBy&&t.append("sort_by",e.sortBy);let r=t.toString(),s=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:s})).rates.map(e=>this._mapRateResponse(e))}}_mapRateResponse(e){return{id:e.id,sig:e.sig,swapSig:e.swap_sig,maker:e.maker,edge:e.edge,fee:{at:e.fee.at,value:e.fee.value,formula:e.fee.formula,components:e.fee.components.map(e=>({at:e.at,name:e.name,type:e.type,value:e.value,percentage:e.percentage,pair:e.pair,amount:e.amount}))},at:e.at,until:e.until,fromMediums:e.from_medium,toMediums:e.to_medium,rate:e.rate,ratio:e.ratio,fromLimits:e.from_limits,toLimits:e.to_limits,createdAt:e.created_at,updatedAt:e.updated_at}}}for(var __rspack_i in exports.BankTransferClient=__webpack_exports__.BankTransferClient,exports.PseClient=__webpack_exports__.PseClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["BankTransferClient","PseClient","SwapClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './bancolombia/bancolombia-client';
2
- export * from './bancolombia/types';
3
- export * from './pse/pse-client';
4
- export * from './pse/types';
5
- export * from './swap-client';
6
- export * from './types';
1
+ export { BankTransferClient } from './bank-transfer/bank-transfer-client';
2
+ export type { BankAccountType, BankDepositInformation, CreateBankTransferOrderParams, CreateBankTransferOrderResult, ExecutionHow, ExecutionResult, IdentificationType, KusamaAccountArgs, OrderType, SupportedBank, SwapOrder, } from './bank-transfer/types';
3
+ export { PseClient } from './pse/pse-client';
4
+ export type { Bank, CreatePseOrderParams, CreatePseOrderResult, DepositInformation, ListBanksResult, PseCustomerData, PsePaymentArgs, } from './pse/types';
5
+ export { SwapClient } from './swap-client';
6
+ export type { Fee, FeeComponent, FeeComponentType, FindRatesParams, FindRatesResult, RateLimits, RateTuple, SwapRate, } from './types';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{BaseClient as t,BloqueConfigError as e}from"@bloque/sdk-core";class a extends t{async create(t){let a=this.httpClient.urn;if(!a)throw new e("User URN is not available. Please connect to a session first.");let r=t.type??"src",s={taker_urn:a,type:r,rate_sig:t.rateSig,from_medium:"kusama",to_medium:"bancolombia",deposit_information:this._mapDepositInformationToWire(t.depositInformation)};"src"===r&&t.amountSrc?s.amount_src=t.amountSrc:"dst"===r&&t.amountDst&&(s.amount_dst=t.amountDst),t.args&&(s.args={account_urn:t.args.accountUrn}),t.nodeId&&(s.node_id=t.nodeId),t.metadata&&(s.metadata=t.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapDepositInformationToWire(t){return{bank_account_type:t.bankAccountType,bank_account_number:t.bankAccountNumber,bank_account_holder_name:t.bankAccountHolderName,bank_account_holder_identification_type:t.bankAccountHolderIdentificationType,bank_account_holder_identification_value:t.bankAccountHolderIdentificationValue}}_mapOrderResponse(t){return{id:t.id,orderSig:t.order_sig,rateSig:t.rate_sig,swapSig:t.swap_sig,taker:t.taker,maker:t.maker,fromAsset:t.from_asset,toAsset:t.to_asset,fromMedium:t.from_medium,toMedium:t.to_medium,fromAmount:t.from_amount,toAmount:t.to_amount,at:t.at,graphId:t.graph_id,status:t.status,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}_mapExecutionResult(t){return{nodeId:t.node_id,result:{status:t.result.status,name:t.result.name,description:t.result.description,how:t.result.how,callbackToken:t.result.callback_token}}}}class r extends t{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(t=>this._mapBankResponse(t))}}async create(t){let a=this.httpClient.urn;if(!a)throw new e("User URN is not available. Please connect to a session first.");let r=t.type??"src",s={taker_urn:a,type:r,rate_sig:t.rateSig,from_medium:"pse",to_medium:t.toMedium,deposit_information:this._mapDepositInformationToWire(t.depositInformation)};"src"===r&&t.amountSrc?s.amount_src=t.amountSrc:"dst"===r&&t.amountDst&&(s.amount_dst=t.amountDst),t.args&&(s.args={bank_code:t.args.bankCode,...t.args.userType&&{user_type:t.args.userType},...t.args.customerEmail&&{customer_email:t.args.customerEmail},...t.args.userLegalIdType&&{user_legal_id_type:t.args.userLegalIdType},...t.args.userLegalId&&{user_legal_id:t.args.userLegalId},...t.args.customerData&&{customer_data:{full_name:t.args.customerData.fullName,phone_number:t.args.customerData.phoneNumber}}}),t.nodeId&&(s.node_id=t.nodeId),t.metadata&&(s.metadata=t.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapBankResponse(t){return{code:t.financial_institution_code,name:t.financial_institution_name}}_mapDepositInformationToWire(t){return{urn:t.urn}}_mapOrderResponse(t){return{id:t.id,orderSig:t.order_sig,rateSig:t.rate_sig,swapSig:t.swap_sig,taker:t.taker,maker:t.maker,fromAsset:t.from_asset,toAsset:t.to_asset,fromMedium:t.from_medium,toMedium:t.to_medium,fromAmount:t.from_amount,toAmount:t.to_amount,at:t.at,graphId:t.graph_id,status:t.status,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}_mapExecutionResult(t){return{nodeId:t.node_id,result:{status:t.result.status,name:t.result.name,description:t.result.description,how:t.result.how,callbackToken:t.result.callback_token}}}}class s extends t{pse;bancolombia;constructor(t){super(t),this.pse=new r(this.httpClient),this.bancolombia=new a(this.httpClient)}async findRates(t){let e=new URLSearchParams,a=JSON.stringify([t.fromAsset,t.toAsset]);e.append("edge",a),e.append("from_medium",JSON.stringify(t.fromMediums)),e.append("to_medium",JSON.stringify(t.toMediums)),void 0!==t.amountSrc&&e.append("amount_src",t.amountSrc),void 0!==t.amountDst&&e.append("amount_dst",t.amountDst),t.sort&&e.append("sort",t.sort),t.sortBy&&e.append("sort_by",t.sortBy);let r=e.toString(),s=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:s})).rates.map(t=>this._mapRateResponse(t))}}_mapRateResponse(t){return{id:t.id,sig:t.sig,swapSig:t.swap_sig,maker:t.maker,edge:t.edge,fee:{at:t.fee.at,value:t.fee.value,formula:t.fee.formula,components:t.fee.components.map(t=>({at:t.at,name:t.name,type:t.type,value:t.value,percentage:t.percentage,pair:t.pair,amount:t.amount}))},at:t.at,until:t.until,fromMediums:t.from_medium,toMediums:t.to_medium,rate:t.rate,ratio:t.ratio,fromLimits:t.from_limits,toLimits:t.to_limits,createdAt:t.created_at,updatedAt:t.updated_at}}}export{a as BancolombiaClient,r as PseClient,s as SwapClient};
1
+ import{BaseClient as t,BloqueConfigError as e}from"@bloque/sdk-core";class a extends t{async create(t){let a=this.httpClient.urn;if(!a)throw new e("User URN is not available. Please connect to a session first.");let r=t.type??"src",s={taker_urn:a,type:r,rate_sig:t.rateSig,from_medium:"kusama",to_medium:t.toMedium,deposit_information:this._mapDepositInformationToWire(t.depositInformation)};"src"===r&&t.amountSrc?s.amount_src=t.amountSrc:"dst"===r&&t.amountDst&&(s.amount_dst=t.amountDst),t.args&&(s.args={account_urn:t.args.sourceAccountUrn}),t.nodeId&&(s.node_id=t.nodeId),t.metadata&&(s.metadata=t.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapDepositInformationToWire(t){return{bank_account_type:t.bankAccountType,bank_account_number:t.bankAccountNumber,bank_account_holder_name:t.bankAccountHolderName,bank_account_holder_identification_type:t.bankAccountHolderIdentificationType,bank_account_holder_identification_value:t.bankAccountHolderIdentificationValue}}_mapOrderResponse(t){return{id:t.id,orderSig:t.order_sig,rateSig:t.rate_sig,swapSig:t.swap_sig,taker:t.taker,maker:t.maker,fromAsset:t.from_asset,toAsset:t.to_asset,fromMedium:t.from_medium,toMedium:t.to_medium,fromAmount:t.from_amount,toAmount:t.to_amount,at:t.at,graphId:t.graph_id,status:t.status,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}_mapExecutionResult(t){return{nodeId:t.node_id,result:{status:t.result.status,name:t.result.name,description:t.result.description,how:t.result.how,callbackToken:t.result.callback_token}}}}class r extends t{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(t=>this._mapBankResponse(t))}}async create(t){let a=this.httpClient.urn;if(!a)throw new e("User URN is not available. Please connect to a session first.");let r=t.type??"src",s={taker_urn:a,type:r,rate_sig:t.rateSig,from_medium:"pse",to_medium:t.toMedium,deposit_information:this._mapDepositInformationToWire(t.depositInformation)};"src"===r&&t.amountSrc?s.amount_src=t.amountSrc:"dst"===r&&t.amountDst&&(s.amount_dst=t.amountDst),t.args&&(s.args={bank_code:t.args.bankCode,...t.args.userType&&{user_type:t.args.userType},...t.args.customerEmail&&{customer_email:t.args.customerEmail},...t.args.userLegalIdType&&{user_legal_id_type:t.args.userLegalIdType},...t.args.userLegalId&&{user_legal_id:t.args.userLegalId},...t.args.customerData&&{customer_data:{full_name:t.args.customerData.fullName,phone_number:t.args.customerData.phoneNumber}}}),t.nodeId&&(s.node_id=t.nodeId),t.metadata&&(s.metadata=t.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapBankResponse(t){return{code:t.financial_institution_code,name:t.financial_institution_name}}_mapDepositInformationToWire(t){return{urn:t.urn}}_mapOrderResponse(t){return{id:t.id,orderSig:t.order_sig,rateSig:t.rate_sig,swapSig:t.swap_sig,taker:t.taker,maker:t.maker,fromAsset:t.from_asset,toAsset:t.to_asset,fromMedium:t.from_medium,toMedium:t.to_medium,fromAmount:t.from_amount,toAmount:t.to_amount,at:t.at,graphId:t.graph_id,status:t.status,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}_mapExecutionResult(t){return{nodeId:t.node_id,result:{status:t.result.status,name:t.result.name,description:t.result.description,how:t.result.how,callbackToken:t.result.callback_token}}}}class s extends t{pse;bankTransfer;constructor(t){super(t),this.pse=new r(this.httpClient),this.bankTransfer=new a(this.httpClient)}async findRates(t){let e=new URLSearchParams,a=JSON.stringify([t.fromAsset,t.toAsset]);e.append("edge",a),e.append("from_medium",JSON.stringify(t.fromMediums)),e.append("to_medium",JSON.stringify(t.toMediums)),void 0!==t.amountSrc&&e.append("amount_src",t.amountSrc),void 0!==t.amountDst&&e.append("amount_dst",t.amountDst),t.sort&&e.append("sort",t.sort),t.sortBy&&e.append("sort_by",t.sortBy);let r=e.toString(),s=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:s})).rates.map(t=>this._mapRateResponse(t))}}_mapRateResponse(t){return{id:t.id,sig:t.sig,swapSig:t.swap_sig,maker:t.maker,edge:t.edge,fee:{at:t.fee.at,value:t.fee.value,formula:t.fee.formula,components:t.fee.components.map(t=>({at:t.at,name:t.name,type:t.type,value:t.value,percentage:t.percentage,pair:t.pair,amount:t.amount}))},at:t.at,until:t.until,fromMediums:t.from_medium,toMediums:t.to_medium,rate:t.rate,ratio:t.ratio,fromLimits:t.from_limits,toLimits:t.to_limits,createdAt:t.created_at,updatedAt:t.updated_at}}}export{a as BankTransferClient,r as PseClient,s as SwapClient};
@@ -1,4 +1,4 @@
1
- import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../bancolombia/types';
1
+ import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../bank-transfer/types';
2
2
  export type { ExecutionHow, ExecutionResult, OrderType, SwapOrder };
3
3
  export interface Bank {
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import type { HttpClient } from '@bloque/sdk-core';
2
2
  import { BaseClient } from '@bloque/sdk-core';
3
- import { BancolombiaClient } from './bancolombia/bancolombia-client';
3
+ import { BankTransferClient } from './bank-transfer/bank-transfer-client';
4
4
  import { PseClient } from './pse/pse-client';
5
5
  import type { FindRatesParams, FindRatesResult } from './types';
6
6
  /**
@@ -8,11 +8,11 @@ import type { FindRatesParams, FindRatesResult } from './types';
8
8
  *
9
9
  * Provides access to exchange rate discovery and swapping functionality.
10
10
  * - pse: PSE utilities (bank listing, etc.)
11
- * - bancolombia: Bancolombia swap functionality
11
+ * - bankTransfer: Generic bank transfer cash-out (supports all Colombian banks)
12
12
  */
13
13
  export declare class SwapClient extends BaseClient {
14
14
  readonly pse: PseClient;
15
- readonly bancolombia: BancolombiaClient;
15
+ readonly bankTransfer: BankTransferClient;
16
16
  constructor(httpClient: HttpClient);
17
17
  /**
18
18
  * Find available exchange rates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-swap",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "bloque",
@@ -34,6 +34,6 @@
34
34
  "node": ">=22"
35
35
  },
36
36
  "dependencies": {
37
- "@bloque/sdk-core": "0.0.33"
37
+ "@bloque/sdk-core": "0.0.34"
38
38
  }
39
39
  }
@@ -1,64 +0,0 @@
1
- import { BaseClient } from '@bloque/sdk-core';
2
- import type { CreateBancolombiaOrderParams, CreateBancolombiaOrderResult } from './types';
3
- /**
4
- * Bancolombia client for Bancolombia-related swaps
5
- *
6
- * Provides access to Bancolombia swap functionality for kusama to bancolombia transactions.
7
- */
8
- export declare class BancolombiaClient extends BaseClient {
9
- /**
10
- * Create a Bancolombia swap order
11
- *
12
- * Creates a swap order using Kusama as the source and Bancolombia as the destination.
13
- * Optionally auto-executes the first instruction node if args are provided.
14
- *
15
- * @param params - Bancolombia order parameters
16
- * @returns Promise resolving to the created order with optional execution result
17
- *
18
- * @example
19
- * ```typescript
20
- * // First find available rates
21
- * const rates = await bloque.swap.findRates({
22
- * fromAsset: 'KSM/12',
23
- * toAsset: 'COP/2',
24
- * fromMediums: ['kusama'],
25
- * toMediums: ['bancolombia'],
26
- * amountSrc: '100000000'
27
- * });
28
- *
29
- * // Create order with auto-execution
30
- * const result = await bloque.swap.bancolombia.create({
31
- * rateSig: rates.rates[0].sig,
32
- * amountSrc: '100000000',
33
- * depositInformation: {
34
- * bankAccountType: 'savings',
35
- * bankAccountNumber: '5740088718',
36
- * bankAccountHolderName: 'david barinas',
37
- * bankAccountHolderIdentificationType: 'CC',
38
- * bankAccountHolderIdentificationValue: '123456789'
39
- * },
40
- * args: {
41
- * accountUrn: 'did:bloque:card:1231231'
42
- * }
43
- * });
44
- *
45
- * console.log('Order created:', result.order.id);
46
- * ```
47
- */
48
- create(params: CreateBancolombiaOrderParams): Promise<CreateBancolombiaOrderResult>;
49
- /**
50
- * Maps SDK deposit information to wire format
51
- * @internal
52
- */
53
- private _mapDepositInformationToWire;
54
- /**
55
- * Maps API order response to SDK format
56
- * @internal
57
- */
58
- private _mapOrderResponse;
59
- /**
60
- * Maps API execution result to SDK format
61
- * @internal
62
- */
63
- private _mapExecutionResult;
64
- }
@@ -1,237 +0,0 @@
1
- /**
2
- * Bancolombia swap types for @bloque/sdk-swap
3
- */
4
- /**
5
- * Bank account type for Bancolombia deposits
6
- */
7
- export type BankAccountType = 'savings' | 'checking';
8
- /**
9
- * Identification type for account holder
10
- */
11
- export type IdentificationType = 'CC' | 'CE' | 'NIT' | 'PP';
12
- /**
13
- * Bancolombia deposit information for direct bank deposits
14
- */
15
- export interface BancolombiaDepositInformation {
16
- /**
17
- * Bank account type
18
- * @example "savings"
19
- */
20
- bankAccountType: BankAccountType;
21
- /**
22
- * Bank account number
23
- * @example "5740088718"
24
- */
25
- bankAccountNumber: string;
26
- /**
27
- * Account holder full name
28
- * @example "david barinas"
29
- */
30
- bankAccountHolderName: string;
31
- /**
32
- * Account holder identification type
33
- * @example "CC"
34
- */
35
- bankAccountHolderIdentificationType: IdentificationType;
36
- /**
37
- * Account holder identification number
38
- * @example "123456789"
39
- */
40
- bankAccountHolderIdentificationValue: string;
41
- }
42
- /**
43
- * Kusama account arguments for swap execution
44
- */
45
- export interface KusamaAccountArgs {
46
- /**
47
- * Kusama account URN for source funds
48
- * @example "did:bloque:card:1231231"
49
- */
50
- accountUrn: string;
51
- }
52
- /**
53
- * Order type for swap
54
- * - 'src': Taker specifies exact source amount to pay
55
- * - 'dst': Taker specifies exact destination amount to receive
56
- */
57
- export type OrderType = 'src' | 'dst';
58
- /**
59
- * Parameters for creating a Bancolombia swap order
60
- */
61
- export interface CreateBancolombiaOrderParams {
62
- /**
63
- * Rate signature from findRates
64
- */
65
- rateSig: string;
66
- /**
67
- * Source amount as bigint string (required if type is 'src')
68
- * @example "100000000" represents the exact amount in KSM smallest unit
69
- */
70
- amountSrc?: string;
71
- /**
72
- * Destination amount as bigint string (required if type is 'dst')
73
- * @example "50000000" represents 500000.00 COP
74
- */
75
- amountDst?: string;
76
- /**
77
- * Order type (default: 'src')
78
- */
79
- type?: OrderType;
80
- /**
81
- * Bancolombia bank account information for fund delivery
82
- */
83
- depositInformation: BancolombiaDepositInformation;
84
- /**
85
- * Kusama account arguments for swap execution
86
- */
87
- args: KusamaAccountArgs;
88
- /**
89
- * Specific node ID to execute (defaults to first node)
90
- */
91
- nodeId?: string;
92
- /**
93
- * Additional metadata for the order
94
- */
95
- metadata?: Record<string, unknown>;
96
- }
97
- /**
98
- * Swap order details
99
- */
100
- export interface SwapOrder {
101
- /**
102
- * Unique order identifier
103
- */
104
- id: string;
105
- /**
106
- * Order signature
107
- */
108
- orderSig: string;
109
- /**
110
- * Rate signature used for this order
111
- */
112
- rateSig: string;
113
- /**
114
- * Swap signature
115
- */
116
- swapSig: string;
117
- /**
118
- * Taker URN
119
- */
120
- taker: string;
121
- /**
122
- * Maker URN
123
- */
124
- maker: string;
125
- /**
126
- * Source asset
127
- */
128
- fromAsset: string;
129
- /**
130
- * Destination asset
131
- */
132
- toAsset: string;
133
- /**
134
- * Source medium
135
- */
136
- fromMedium: string;
137
- /**
138
- * Destination medium
139
- */
140
- toMedium: string;
141
- /**
142
- * Source amount
143
- */
144
- fromAmount: string;
145
- /**
146
- * Destination amount
147
- */
148
- toAmount: string;
149
- /**
150
- * Timestamp when the order was created (as string)
151
- */
152
- at: string;
153
- /**
154
- * Instruction graph ID for tracking execution
155
- */
156
- graphId: string;
157
- /**
158
- * Order status (pending, in_progress, completed, failed)
159
- */
160
- status: string;
161
- /**
162
- * Additional metadata
163
- */
164
- metadata?: Record<string, unknown>;
165
- /**
166
- * Creation timestamp
167
- */
168
- createdAt: string;
169
- /**
170
- * Last update timestamp
171
- */
172
- updatedAt: string;
173
- }
174
- /**
175
- * Redirect instructions for completing the payment
176
- */
177
- export interface ExecutionHow {
178
- /**
179
- * Type of action required (e.g., "REDIRECT")
180
- */
181
- type: string;
182
- /**
183
- * URL to redirect the user to complete the payment
184
- */
185
- url: string;
186
- }
187
- /**
188
- * Execution result from auto-execution
189
- */
190
- export interface ExecutionResult {
191
- /**
192
- * Node ID that was executed
193
- */
194
- nodeId: string;
195
- /**
196
- * Execution result details
197
- */
198
- result: {
199
- /**
200
- * Execution status (e.g., "paused")
201
- */
202
- status: string;
203
- /**
204
- * Name of the current step
205
- */
206
- name?: string;
207
- /**
208
- * Description of what the user needs to do
209
- */
210
- description?: string;
211
- /**
212
- * Instructions for completing this step
213
- */
214
- how?: ExecutionHow;
215
- /**
216
- * Callback token for tracking
217
- */
218
- callbackToken?: string;
219
- };
220
- }
221
- /**
222
- * Result of creating a Bancolombia swap order
223
- */
224
- export interface CreateBancolombiaOrderResult {
225
- /**
226
- * The created order
227
- */
228
- order: SwapOrder;
229
- /**
230
- * Execution result (if args were provided for auto-execution)
231
- */
232
- execution?: ExecutionResult;
233
- /**
234
- * Request ID for tracking
235
- */
236
- requestId: string;
237
- }