@bloque/sdk-swap 0.0.29 → 0.0.31
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.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/wire-types.d.ts +60 -88
- package/dist/pse/pse-client.d.ts +39 -48
- package/dist/pse/types.d.ts +131 -144
- package/package.json +2 -2
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__,{SwapClient:()=>SwapClient,PseClient:()=>PseClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");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
|
|
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,PseClient:()=>PseClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");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.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"ledgerAccountId"in e&&e.ledgerAccountId?{ledger_account_id:e.ledgerAccountId}:"bankCode"in e&&e.bankCode?{bank_code:e.bankCode,account_number:e.accountNumber,account_type:e.accountType}:e}_mapDepositInformationFromWire(e){return"ledger_account_id"in e&&e.ledger_account_id?{ledgerAccountId:e.ledger_account_id}:"bank_code"in e&&e.bank_code?{bankCode:e.bank_code,accountNumber:e.account_number,accountType:e.account_type}:e}_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,depositInformation:this._mapDepositInformationFromWire(e.deposit_information),at:e.at,graphId:e.graph_id,status:e.status,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,args:e.result.args,description:e.result.description,checkoutUrl:e.result.checkout_url}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;constructor(e){super(e),this.pse=new PseClient(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.PseClient=__webpack_exports__.PseClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["PseClient","SwapClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BaseClient as e}from"@bloque/sdk-core";class
|
|
1
|
+
import{BaseClient as e,BloqueConfigError as t}from"@bloque/sdk-core";class a extends e{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 a=this.httpClient.urn;if(!a)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",r={taker_urn:a,type:o,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation??{})};"src"===o&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===o&&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.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"ledgerAccountId"in e&&e.ledgerAccountId?{ledger_account_id:e.ledgerAccountId}:"bankCode"in e&&e.bankCode?{bank_code:e.bankCode,account_number:e.accountNumber,account_type:e.accountType}:e}_mapDepositInformationFromWire(e){return"ledger_account_id"in e&&e.ledger_account_id?{ledgerAccountId:e.ledger_account_id}:"bank_code"in e&&e.bank_code?{bankCode:e.bank_code,accountNumber:e.account_number,accountType:e.account_type}:e}_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,depositInformation:this._mapDepositInformationFromWire(e.deposit_information),at:e.at,graphId:e.graph_id,status:e.status,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,args:e.result.args,description:e.result.description,checkoutUrl:e.result.checkout_url}}}}class o extends e{pse;constructor(e){super(e),this.pse=new a(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 o=t.toString(),r=`/api/rates?${o}`;return{rates:(await this.httpClient.request({method:"GET",path:r})).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}}}export{a as PseClient,o as SwapClient};
|
|
@@ -68,122 +68,94 @@ export interface PseBank {
|
|
|
68
68
|
export interface ListPseBanksResponse {
|
|
69
69
|
banks: PseBank[];
|
|
70
70
|
}
|
|
71
|
-
type Currency = 'DUSD/6' | 'COP/2' | 'KSM/12';
|
|
72
71
|
/**
|
|
73
72
|
* @internal
|
|
74
|
-
*
|
|
73
|
+
* Order type for swap (source or destination amount specified)
|
|
75
74
|
*/
|
|
76
|
-
export
|
|
77
|
-
name: string;
|
|
78
|
-
amount: string;
|
|
79
|
-
sku?: string;
|
|
80
|
-
description?: string;
|
|
81
|
-
quantity: number;
|
|
82
|
-
image_url?: string;
|
|
83
|
-
}
|
|
75
|
+
export type OrderType = 'src' | 'dst';
|
|
84
76
|
/**
|
|
85
77
|
* @internal
|
|
86
|
-
*
|
|
78
|
+
* Deposit information for cash-in (fiat to crypto)
|
|
87
79
|
*/
|
|
88
|
-
export interface
|
|
89
|
-
|
|
90
|
-
description?: string;
|
|
91
|
-
currency: Currency;
|
|
92
|
-
payment_type: string;
|
|
93
|
-
image_url?: string;
|
|
94
|
-
items: CreatePaymentItemInput[];
|
|
95
|
-
success_url?: string;
|
|
96
|
-
cancel_url?: string;
|
|
97
|
-
metadata?: Record<string, unknown>;
|
|
98
|
-
expires_at?: string;
|
|
99
|
-
webhook_url?: string;
|
|
80
|
+
export interface DepositInformationCashIn {
|
|
81
|
+
ledger_account_id?: string;
|
|
100
82
|
}
|
|
101
83
|
/**
|
|
102
84
|
* @internal
|
|
103
|
-
*
|
|
85
|
+
* Deposit information for cash-out (crypto to fiat)
|
|
104
86
|
*/
|
|
105
|
-
export interface
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
description?: string;
|
|
110
|
-
quantity: number;
|
|
111
|
-
image_url?: string;
|
|
87
|
+
export interface DepositInformationCashOut {
|
|
88
|
+
bank_code?: string;
|
|
89
|
+
account_number?: string;
|
|
90
|
+
account_type?: string;
|
|
112
91
|
}
|
|
113
92
|
/**
|
|
114
93
|
* @internal
|
|
115
|
-
*
|
|
94
|
+
* Deposit information union type
|
|
116
95
|
*/
|
|
117
|
-
export
|
|
118
|
-
status: string;
|
|
119
|
-
}
|
|
96
|
+
export type DepositInformation = DepositInformationCashIn | DepositInformationCashOut | Record<string, unknown>;
|
|
120
97
|
/**
|
|
121
98
|
* @internal
|
|
122
|
-
*
|
|
99
|
+
* Create order input for PUT /api/order
|
|
123
100
|
*/
|
|
124
|
-
export interface
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
101
|
+
export interface CreateOrderInput {
|
|
102
|
+
taker_urn: string;
|
|
103
|
+
type: OrderType;
|
|
104
|
+
rate_sig: string;
|
|
105
|
+
from_medium: string;
|
|
106
|
+
to_medium: string;
|
|
107
|
+
amount_src?: string;
|
|
108
|
+
amount_dst?: string;
|
|
109
|
+
deposit_information: DepositInformation;
|
|
110
|
+
args?: Record<string, unknown>;
|
|
111
|
+
node_id?: string;
|
|
135
112
|
metadata?: Record<string, unknown>;
|
|
136
|
-
tax?: number;
|
|
137
|
-
discount_code?: string;
|
|
138
|
-
webhook_url?: string;
|
|
139
|
-
payout_route: unknown[];
|
|
140
|
-
summary: PaymentSummaryResponse;
|
|
141
|
-
expires_at?: string;
|
|
142
|
-
created_at: string;
|
|
143
|
-
updated_at: string;
|
|
144
|
-
payment_type: string;
|
|
145
|
-
items: PaymentItemResponse[];
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* @internal
|
|
149
|
-
* Create payment API response wrapper
|
|
150
|
-
*/
|
|
151
|
-
export interface CreatePaymentResponse {
|
|
152
|
-
payment: PaymentResponse;
|
|
153
113
|
}
|
|
154
114
|
/**
|
|
155
115
|
* @internal
|
|
156
|
-
*
|
|
116
|
+
* Order from API response
|
|
157
117
|
*/
|
|
158
|
-
export interface
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
118
|
+
export interface OrderResponse {
|
|
119
|
+
id: string;
|
|
120
|
+
order_sig: string;
|
|
121
|
+
rate_sig: string;
|
|
122
|
+
swap_sig: string;
|
|
123
|
+
taker: string;
|
|
124
|
+
maker: string;
|
|
125
|
+
from_asset: string;
|
|
126
|
+
to_asset: string;
|
|
127
|
+
from_medium: string;
|
|
128
|
+
to_medium: string;
|
|
129
|
+
from_amount: string;
|
|
130
|
+
to_amount: string;
|
|
131
|
+
deposit_information: DepositInformation;
|
|
132
|
+
at: number;
|
|
133
|
+
graph_id: string;
|
|
134
|
+
status: string;
|
|
135
|
+
created_at: string;
|
|
136
|
+
updated_at: string;
|
|
163
137
|
}
|
|
164
138
|
/**
|
|
165
139
|
* @internal
|
|
166
|
-
*
|
|
140
|
+
* Execution result from auto-execution
|
|
167
141
|
*/
|
|
168
|
-
export interface
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
142
|
+
export interface ExecutionResult {
|
|
143
|
+
node_id: string;
|
|
144
|
+
result: {
|
|
145
|
+
status: string;
|
|
146
|
+
args?: unknown[];
|
|
147
|
+
description?: string;
|
|
148
|
+
checkout_url?: string;
|
|
149
|
+
};
|
|
173
150
|
}
|
|
174
151
|
/**
|
|
175
152
|
* @internal
|
|
176
|
-
*
|
|
153
|
+
* Create order response from PUT /api/order
|
|
177
154
|
*/
|
|
178
|
-
export interface
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
checkout_url: string;
|
|
185
|
-
order_id: string;
|
|
186
|
-
order_status: string;
|
|
187
|
-
created_at: string;
|
|
155
|
+
export interface CreateOrderResponse {
|
|
156
|
+
result: {
|
|
157
|
+
order: OrderResponse;
|
|
158
|
+
execution?: ExecutionResult;
|
|
159
|
+
};
|
|
160
|
+
req_id: string;
|
|
188
161
|
}
|
|
189
|
-
export {};
|
package/dist/pse/pse-client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreatePseOrderParams, CreatePseOrderResult, ListBanksResult } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* PSE client for PSE-related utilities
|
|
5
5
|
*
|
|
@@ -24,73 +24,64 @@ export declare class PseClient extends BaseClient {
|
|
|
24
24
|
*/
|
|
25
25
|
banks(): Promise<ListBanksResult>;
|
|
26
26
|
/**
|
|
27
|
-
* Create a PSE
|
|
27
|
+
* Create a PSE swap order
|
|
28
28
|
*
|
|
29
|
-
* Creates a
|
|
30
|
-
*
|
|
29
|
+
* Creates a swap order using PSE as the source payment medium.
|
|
30
|
+
* Optionally auto-executes the first instruction node if args are provided.
|
|
31
31
|
*
|
|
32
|
-
* @param params -
|
|
33
|
-
* @returns Promise resolving to the created
|
|
32
|
+
* @param params - PSE order parameters
|
|
33
|
+
* @returns Promise resolving to the created order with optional execution result
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
36
|
* ```typescript
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
37
|
+
* // First find available rates
|
|
38
|
+
* const rates = await bloque.swap.findRates({
|
|
39
|
+
* fromAsset: 'COP/2',
|
|
40
|
+
* toAsset: 'DUSD/6',
|
|
41
|
+
* fromMediums: ['pse'],
|
|
42
|
+
* toMediums: ['kreivo'],
|
|
43
|
+
* amountSrc: '1000000'
|
|
42
44
|
* });
|
|
43
45
|
*
|
|
44
|
-
* //
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* Initiates the PSE payment flow for a previously created top-up.
|
|
53
|
-
* Returns a checkout URL where the user should be redirected to complete the payment.
|
|
54
|
-
*
|
|
55
|
-
* @param params - PSE payment parameters
|
|
56
|
-
* @returns Promise resolving to PSE payment result with checkout URL
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // First create a top-up
|
|
61
|
-
* const topUp = await bloque.swap.pse.createTopUp({...});
|
|
62
|
-
*
|
|
63
|
-
* // Then initiate PSE payment with user details
|
|
64
|
-
* const result = await bloque.swap.pse.initiatePayment({
|
|
65
|
-
* paymentUrn: topUp.payment.urn,
|
|
66
|
-
* payee: {
|
|
67
|
-
* name: 'Juan Pérez García',
|
|
68
|
-
* email: 'juan.perez@example.com',
|
|
69
|
-
* idType: 'CC',
|
|
70
|
-
* idNumber: '1055228746',
|
|
71
|
-
* },
|
|
72
|
-
* personType: 'natural',
|
|
73
|
-
* bankCode: '1',
|
|
46
|
+
* // Create order with auto-execution
|
|
47
|
+
* const result = await bloque.swap.pse.create({
|
|
48
|
+
* rateSig: rates.rates[0].sig,
|
|
49
|
+
* toMedium: 'kreivo',
|
|
50
|
+
* amountSrc: '1000000',
|
|
51
|
+
* depositInformation: { ledgerAccountId: '0x123...' },
|
|
52
|
+
* args: { bankCode: '1007' }
|
|
74
53
|
* });
|
|
75
54
|
*
|
|
76
|
-
* //
|
|
77
|
-
*
|
|
55
|
+
* // If execution returned a checkout URL, redirect user
|
|
56
|
+
* if (result.execution?.result.checkoutUrl) {
|
|
57
|
+
* window.location.href = result.execution.result.checkoutUrl;
|
|
58
|
+
* }
|
|
78
59
|
* ```
|
|
79
60
|
*/
|
|
80
|
-
|
|
61
|
+
create(params: CreatePseOrderParams): Promise<CreatePseOrderResult>;
|
|
81
62
|
/**
|
|
82
63
|
* Maps API bank response to SDK format
|
|
83
64
|
* @internal
|
|
84
65
|
*/
|
|
85
66
|
private _mapBankResponse;
|
|
86
67
|
/**
|
|
87
|
-
* Maps
|
|
68
|
+
* Maps SDK deposit information to wire format
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
private _mapDepositInformationToWire;
|
|
72
|
+
/**
|
|
73
|
+
* Maps wire deposit information to SDK format
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
private _mapDepositInformationFromWire;
|
|
77
|
+
/**
|
|
78
|
+
* Maps API order response to SDK format
|
|
88
79
|
* @internal
|
|
89
80
|
*/
|
|
90
|
-
private
|
|
81
|
+
private _mapOrderResponse;
|
|
91
82
|
/**
|
|
92
|
-
* Maps API
|
|
83
|
+
* Maps API execution result to SDK format
|
|
93
84
|
* @internal
|
|
94
85
|
*/
|
|
95
|
-
private
|
|
86
|
+
private _mapExecutionResult;
|
|
96
87
|
}
|
package/dist/pse/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type Currency = 'DUSD/6' | 'COP/2' | 'KSM/12';
|
|
2
1
|
export interface Bank {
|
|
3
2
|
/**
|
|
4
3
|
* Financial institution code
|
|
@@ -12,125 +11,153 @@ export interface Bank {
|
|
|
12
11
|
export interface ListBanksResult {
|
|
13
12
|
banks: Bank[];
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Order type for swap
|
|
16
|
+
* - 'src': Taker specifies exact source amount to pay
|
|
17
|
+
* - 'dst': Taker specifies exact destination amount to receive
|
|
18
|
+
*/
|
|
19
|
+
export type OrderType = 'src' | 'dst';
|
|
20
|
+
/**
|
|
21
|
+
* Deposit information for cash-in (fiat to crypto)
|
|
22
|
+
*/
|
|
23
|
+
export interface DepositInformationCashIn {
|
|
24
|
+
ledgerAccountId?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Deposit information for cash-out (crypto to fiat)
|
|
28
|
+
*/
|
|
29
|
+
export interface DepositInformationCashOut {
|
|
30
|
+
bankCode?: string;
|
|
31
|
+
accountNumber?: string;
|
|
32
|
+
accountType?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Deposit information union type
|
|
36
|
+
*/
|
|
37
|
+
export type DepositInformation = DepositInformationCashIn | DepositInformationCashOut | Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* PSE payment arguments for auto-execution
|
|
40
|
+
*/
|
|
41
|
+
export interface PsePaymentArgs {
|
|
16
42
|
/**
|
|
17
|
-
*
|
|
43
|
+
* Bank code from PSE banks list
|
|
18
44
|
*/
|
|
19
|
-
|
|
45
|
+
bankCode: string;
|
|
20
46
|
/**
|
|
21
|
-
*
|
|
47
|
+
* User type: '0' for natural person, '1' for legal entity
|
|
22
48
|
*/
|
|
23
|
-
|
|
49
|
+
userType?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parameters for creating a PSE swap order
|
|
53
|
+
*/
|
|
54
|
+
export interface CreatePseOrderParams {
|
|
24
55
|
/**
|
|
25
|
-
*
|
|
56
|
+
* Rate signature from findRates
|
|
26
57
|
*/
|
|
27
|
-
|
|
58
|
+
rateSig: string;
|
|
28
59
|
/**
|
|
29
|
-
*
|
|
60
|
+
* Destination medium (e.g., 'kreivo', 'bloque')
|
|
30
61
|
*/
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
export interface PaymentItemResult {
|
|
62
|
+
toMedium: string;
|
|
34
63
|
/**
|
|
35
|
-
*
|
|
64
|
+
* Source amount as bigint string (required if type is 'src')
|
|
65
|
+
* @example "1000000" represents 10000.00 for COP/2
|
|
36
66
|
*/
|
|
37
|
-
|
|
67
|
+
amountSrc?: string;
|
|
38
68
|
/**
|
|
39
|
-
*
|
|
69
|
+
* Destination amount as bigint string (required if type is 'dst')
|
|
40
70
|
*/
|
|
41
|
-
|
|
71
|
+
amountDst?: string;
|
|
42
72
|
/**
|
|
43
|
-
*
|
|
73
|
+
* Order type (default: 'src')
|
|
44
74
|
*/
|
|
45
|
-
|
|
75
|
+
type?: OrderType;
|
|
46
76
|
/**
|
|
47
|
-
*
|
|
77
|
+
* Deposit information for fund delivery
|
|
48
78
|
*/
|
|
49
|
-
|
|
79
|
+
depositInformation?: DepositInformation;
|
|
50
80
|
/**
|
|
51
|
-
*
|
|
81
|
+
* PSE payment arguments for auto-execution
|
|
52
82
|
*/
|
|
53
|
-
|
|
83
|
+
args?: PsePaymentArgs;
|
|
54
84
|
/**
|
|
55
|
-
*
|
|
85
|
+
* Specific node ID to execute (defaults to first node)
|
|
56
86
|
*/
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
export interface PaymentSummary {
|
|
87
|
+
nodeId?: string;
|
|
60
88
|
/**
|
|
61
|
-
*
|
|
89
|
+
* Additional metadata for the order
|
|
62
90
|
*/
|
|
63
|
-
|
|
91
|
+
metadata?: Record<string, unknown>;
|
|
64
92
|
}
|
|
65
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Swap order details
|
|
95
|
+
*/
|
|
96
|
+
export interface SwapOrder {
|
|
66
97
|
/**
|
|
67
|
-
*
|
|
98
|
+
* Unique order identifier
|
|
68
99
|
*/
|
|
69
|
-
|
|
100
|
+
id: string;
|
|
70
101
|
/**
|
|
71
|
-
*
|
|
102
|
+
* Order signature
|
|
72
103
|
*/
|
|
73
|
-
|
|
104
|
+
orderSig: string;
|
|
74
105
|
/**
|
|
75
|
-
*
|
|
106
|
+
* Rate signature used for this order
|
|
76
107
|
*/
|
|
77
|
-
|
|
108
|
+
rateSig: string;
|
|
78
109
|
/**
|
|
79
|
-
*
|
|
110
|
+
* Swap signature
|
|
80
111
|
*/
|
|
81
|
-
|
|
112
|
+
swapSig: string;
|
|
82
113
|
/**
|
|
83
|
-
*
|
|
114
|
+
* Taker URN
|
|
84
115
|
*/
|
|
85
|
-
|
|
116
|
+
taker: string;
|
|
86
117
|
/**
|
|
87
|
-
*
|
|
118
|
+
* Maker URN
|
|
88
119
|
*/
|
|
89
|
-
|
|
120
|
+
maker: string;
|
|
90
121
|
/**
|
|
91
|
-
*
|
|
122
|
+
* Source asset
|
|
92
123
|
*/
|
|
93
|
-
|
|
124
|
+
fromAsset: string;
|
|
94
125
|
/**
|
|
95
|
-
*
|
|
126
|
+
* Destination asset
|
|
96
127
|
*/
|
|
97
|
-
|
|
128
|
+
toAsset: string;
|
|
98
129
|
/**
|
|
99
|
-
*
|
|
130
|
+
* Source medium
|
|
100
131
|
*/
|
|
101
|
-
|
|
132
|
+
fromMedium: string;
|
|
102
133
|
/**
|
|
103
|
-
*
|
|
134
|
+
* Destination medium
|
|
104
135
|
*/
|
|
105
|
-
|
|
136
|
+
toMedium: string;
|
|
106
137
|
/**
|
|
107
|
-
*
|
|
138
|
+
* Source amount
|
|
108
139
|
*/
|
|
109
|
-
|
|
140
|
+
fromAmount: string;
|
|
110
141
|
/**
|
|
111
|
-
*
|
|
142
|
+
* Destination amount
|
|
112
143
|
*/
|
|
113
|
-
|
|
144
|
+
toAmount: string;
|
|
114
145
|
/**
|
|
115
|
-
*
|
|
146
|
+
* Deposit information
|
|
116
147
|
*/
|
|
117
|
-
|
|
148
|
+
depositInformation: DepositInformation;
|
|
118
149
|
/**
|
|
119
|
-
*
|
|
150
|
+
* Timestamp when the order was created
|
|
120
151
|
*/
|
|
121
|
-
|
|
152
|
+
at: number;
|
|
122
153
|
/**
|
|
123
|
-
*
|
|
154
|
+
* Instruction graph ID for tracking execution
|
|
124
155
|
*/
|
|
125
|
-
|
|
156
|
+
graphId: string;
|
|
126
157
|
/**
|
|
127
|
-
*
|
|
158
|
+
* Order status (pending, in_progress, completed, failed)
|
|
128
159
|
*/
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Expiration date
|
|
132
|
-
*/
|
|
133
|
-
expiresAt?: string;
|
|
160
|
+
status: string;
|
|
134
161
|
/**
|
|
135
162
|
* Creation timestamp
|
|
136
163
|
*/
|
|
@@ -139,91 +166,51 @@ export interface Payment {
|
|
|
139
166
|
* Last update timestamp
|
|
140
167
|
*/
|
|
141
168
|
updatedAt: string;
|
|
142
|
-
/**
|
|
143
|
-
* Payment type
|
|
144
|
-
*/
|
|
145
|
-
paymentType: string;
|
|
146
|
-
/**
|
|
147
|
-
* Payment items
|
|
148
|
-
*/
|
|
149
|
-
items: PaymentItemResult[];
|
|
150
169
|
}
|
|
151
|
-
|
|
152
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Execution result from auto-execution
|
|
172
|
+
*/
|
|
173
|
+
export interface ExecutionResult {
|
|
174
|
+
/**
|
|
175
|
+
* Node ID that was executed
|
|
176
|
+
*/
|
|
177
|
+
nodeId: string;
|
|
178
|
+
/**
|
|
179
|
+
* Execution result details
|
|
180
|
+
*/
|
|
181
|
+
result: {
|
|
182
|
+
/**
|
|
183
|
+
* Execution status
|
|
184
|
+
*/
|
|
185
|
+
status: string;
|
|
186
|
+
/**
|
|
187
|
+
* Additional arguments
|
|
188
|
+
*/
|
|
189
|
+
args?: unknown[];
|
|
190
|
+
/**
|
|
191
|
+
* Description of the result
|
|
192
|
+
*/
|
|
193
|
+
description?: string;
|
|
194
|
+
/**
|
|
195
|
+
* PSE checkout URL (if applicable)
|
|
196
|
+
*/
|
|
197
|
+
checkoutUrl?: string;
|
|
198
|
+
};
|
|
153
199
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
name: string;
|
|
200
|
+
/**
|
|
201
|
+
* Result of creating a PSE swap order
|
|
202
|
+
*/
|
|
203
|
+
export interface CreatePseOrderResult {
|
|
159
204
|
/**
|
|
160
|
-
*
|
|
205
|
+
* The created order
|
|
161
206
|
*/
|
|
162
|
-
|
|
207
|
+
order: SwapOrder;
|
|
163
208
|
/**
|
|
164
|
-
*
|
|
209
|
+
* Execution result (if args were provided for auto-execution)
|
|
165
210
|
*/
|
|
166
|
-
|
|
211
|
+
execution?: ExecutionResult;
|
|
167
212
|
/**
|
|
168
|
-
* ID
|
|
213
|
+
* Request ID for tracking
|
|
169
214
|
*/
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
export type PersonType = 'natural' | 'juridica';
|
|
173
|
-
export interface InitiatePsePaymentParams {
|
|
174
|
-
/**
|
|
175
|
-
* Payment URN from createTopUp
|
|
176
|
-
*/
|
|
177
|
-
paymentUrn: string;
|
|
178
|
-
/**
|
|
179
|
-
* Payee information
|
|
180
|
-
*/
|
|
181
|
-
payee: PsePayee;
|
|
182
|
-
/**
|
|
183
|
-
* Person type (natural or juridica)
|
|
184
|
-
*/
|
|
185
|
-
personType: PersonType;
|
|
186
|
-
/**
|
|
187
|
-
* Bank code from banks list
|
|
188
|
-
*/
|
|
189
|
-
bankCode: string;
|
|
190
|
-
}
|
|
191
|
-
export interface InitiatePsePaymentResult {
|
|
192
|
-
/**
|
|
193
|
-
* Payment ID
|
|
194
|
-
*/
|
|
195
|
-
paymentId: string;
|
|
196
|
-
/**
|
|
197
|
-
* Payment status
|
|
198
|
-
*/
|
|
199
|
-
status: string;
|
|
200
|
-
/**
|
|
201
|
-
* Status message
|
|
202
|
-
*/
|
|
203
|
-
message: string;
|
|
204
|
-
/**
|
|
205
|
-
* Payment amount
|
|
206
|
-
*/
|
|
207
|
-
amount: string;
|
|
208
|
-
/**
|
|
209
|
-
* Currency
|
|
210
|
-
*/
|
|
211
|
-
currency: Currency;
|
|
212
|
-
/**
|
|
213
|
-
* PSE checkout URL to redirect the user
|
|
214
|
-
*/
|
|
215
|
-
checkoutUrl: string;
|
|
216
|
-
/**
|
|
217
|
-
* Order ID
|
|
218
|
-
*/
|
|
219
|
-
orderId: string;
|
|
220
|
-
/**
|
|
221
|
-
* Order status
|
|
222
|
-
*/
|
|
223
|
-
orderStatus: string;
|
|
224
|
-
/**
|
|
225
|
-
* Creation timestamp
|
|
226
|
-
*/
|
|
227
|
-
createdAt: string;
|
|
215
|
+
requestId: string;
|
|
228
216
|
}
|
|
229
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-swap",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
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.
|
|
37
|
+
"@bloque/sdk-core": "0.0.31"
|
|
38
38
|
}
|
|
39
39
|
}
|