@bloque/sdk-swap 0.0.30 → 0.0.32
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 +55 -88
- package/dist/pse/pse-client.d.ts +44 -47
- package/dist/pse/types.d.ts +153 -132
- 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.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}}}),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;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(),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.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 s=e.type??"src",r={taker_urn:a,type:s,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===s&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===s&&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}}}),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 s 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 s=t.toString(),r=`/api/rates?${s}`;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,s as SwapClient};
|
|
@@ -68,122 +68,89 @@ 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 PSE top-up
|
|
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 DepositInformation {
|
|
81
|
+
urn: string;
|
|
100
82
|
}
|
|
101
83
|
/**
|
|
102
84
|
* @internal
|
|
103
|
-
*
|
|
85
|
+
* Create order input for PUT /api/order
|
|
104
86
|
*/
|
|
105
|
-
export interface
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
87
|
+
export interface CreateOrderInput {
|
|
88
|
+
taker_urn: string;
|
|
89
|
+
type: OrderType;
|
|
90
|
+
rate_sig: string;
|
|
91
|
+
from_medium: string;
|
|
92
|
+
to_medium: string;
|
|
93
|
+
amount_src?: string;
|
|
94
|
+
amount_dst?: string;
|
|
95
|
+
deposit_information: DepositInformation;
|
|
96
|
+
args?: Record<string, unknown>;
|
|
97
|
+
node_id?: string;
|
|
98
|
+
metadata?: Record<string, unknown>;
|
|
112
99
|
}
|
|
113
100
|
/**
|
|
114
101
|
* @internal
|
|
115
|
-
*
|
|
102
|
+
* Order from API response
|
|
116
103
|
*/
|
|
117
|
-
export interface
|
|
104
|
+
export interface OrderResponse {
|
|
105
|
+
id: string;
|
|
106
|
+
order_sig: string;
|
|
107
|
+
rate_sig: string;
|
|
108
|
+
swap_sig: string;
|
|
109
|
+
taker: string;
|
|
110
|
+
maker: string;
|
|
111
|
+
from_asset: string;
|
|
112
|
+
to_asset: string;
|
|
113
|
+
from_medium: string;
|
|
114
|
+
to_medium: string;
|
|
115
|
+
from_amount: string;
|
|
116
|
+
to_amount: string;
|
|
117
|
+
at: string;
|
|
118
|
+
graph_id: string;
|
|
118
119
|
status: string;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* @internal
|
|
122
|
-
* Payment response from API
|
|
123
|
-
*/
|
|
124
|
-
export interface PaymentResponse {
|
|
125
|
-
urn: string;
|
|
126
|
-
owner_urn: string;
|
|
127
|
-
name: string;
|
|
128
|
-
description?: string;
|
|
129
|
-
currency: Currency;
|
|
130
|
-
amount: number;
|
|
131
|
-
url: string;
|
|
132
|
-
success_url?: string;
|
|
133
|
-
cancel_url?: string;
|
|
134
|
-
image_url?: string;
|
|
135
120
|
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
121
|
created_at: string;
|
|
143
122
|
updated_at: string;
|
|
144
|
-
payment_type: string;
|
|
145
|
-
items: PaymentItemResponse[];
|
|
146
123
|
}
|
|
147
124
|
/**
|
|
148
125
|
* @internal
|
|
149
|
-
*
|
|
126
|
+
* Execution redirect instructions
|
|
150
127
|
*/
|
|
151
|
-
export interface
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @internal
|
|
156
|
-
* Payee info for PSE payment
|
|
157
|
-
*/
|
|
158
|
-
export interface PsePayeeInput {
|
|
159
|
-
name: string;
|
|
160
|
-
email: string;
|
|
161
|
-
id_type: string;
|
|
162
|
-
id_number: string;
|
|
128
|
+
export interface ExecutionHow {
|
|
129
|
+
type: string;
|
|
130
|
+
url: string;
|
|
163
131
|
}
|
|
164
132
|
/**
|
|
165
133
|
* @internal
|
|
166
|
-
*
|
|
134
|
+
* Execution result from auto-execution
|
|
167
135
|
*/
|
|
168
|
-
export interface
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
136
|
+
export interface ExecutionResult {
|
|
137
|
+
node_id: string;
|
|
138
|
+
result: {
|
|
139
|
+
status: string;
|
|
140
|
+
name?: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
how?: ExecutionHow;
|
|
143
|
+
callback_token?: string;
|
|
144
|
+
};
|
|
173
145
|
}
|
|
174
146
|
/**
|
|
175
147
|
* @internal
|
|
176
|
-
*
|
|
148
|
+
* Create order response from PUT /api/order
|
|
177
149
|
*/
|
|
178
|
-
export interface
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
checkout_url: string;
|
|
185
|
-
order_id: string;
|
|
186
|
-
order_status: string;
|
|
187
|
-
created_at: string;
|
|
150
|
+
export interface CreateOrderResponse {
|
|
151
|
+
result: {
|
|
152
|
+
order: OrderResponse;
|
|
153
|
+
execution?: ExecutionResult;
|
|
154
|
+
};
|
|
155
|
+
req_id: string;
|
|
188
156
|
}
|
|
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,70 @@ 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: ['kusama'],
|
|
43
|
+
* amountSrc: '10000000'
|
|
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',
|
|
46
|
+
* // Create order with auto-execution
|
|
47
|
+
* const result = await bloque.swap.pse.create({
|
|
48
|
+
* rateSig: rates.rates[0].sig,
|
|
49
|
+
* toMedium: 'kusama',
|
|
50
|
+
* amountSrc: '10000000',
|
|
51
|
+
* depositInformation: {
|
|
52
|
+
* urn: 'did:bloque:account:card:usr-xxx:crd-xxx'
|
|
71
53
|
* },
|
|
72
|
-
*
|
|
73
|
-
*
|
|
54
|
+
* args: {
|
|
55
|
+
* bankCode: '1',
|
|
56
|
+
* userType: 'natural',
|
|
57
|
+
* customerEmail: 'user@example.com',
|
|
58
|
+
* userLegalIdType: 'CC',
|
|
59
|
+
* userLegalId: '1234567890',
|
|
60
|
+
* customerData: {
|
|
61
|
+
* fullName: 'John Doe'
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
74
64
|
* });
|
|
75
65
|
*
|
|
76
|
-
* //
|
|
77
|
-
*
|
|
66
|
+
* // If execution returned a checkout URL, redirect user
|
|
67
|
+
* if (result.execution?.result.checkoutUrl) {
|
|
68
|
+
* window.location.href = result.execution.result.checkoutUrl;
|
|
69
|
+
* }
|
|
78
70
|
* ```
|
|
79
71
|
*/
|
|
80
|
-
|
|
72
|
+
create(params: CreatePseOrderParams): Promise<CreatePseOrderResult>;
|
|
81
73
|
/**
|
|
82
74
|
* Maps API bank response to SDK format
|
|
83
75
|
* @internal
|
|
84
76
|
*/
|
|
85
77
|
private _mapBankResponse;
|
|
86
78
|
/**
|
|
87
|
-
* Maps
|
|
79
|
+
* Maps SDK deposit information to wire format
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
private _mapDepositInformationToWire;
|
|
83
|
+
/**
|
|
84
|
+
* Maps API order response to SDK format
|
|
88
85
|
* @internal
|
|
89
86
|
*/
|
|
90
|
-
private
|
|
87
|
+
private _mapOrderResponse;
|
|
91
88
|
/**
|
|
92
|
-
* Maps API
|
|
89
|
+
* Maps API execution result to SDK format
|
|
93
90
|
* @internal
|
|
94
91
|
*/
|
|
95
|
-
private
|
|
92
|
+
private _mapExecutionResult;
|
|
96
93
|
}
|
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,218 +11,240 @@ export interface Bank {
|
|
|
12
11
|
export interface ListBanksResult {
|
|
13
12
|
banks: Bank[];
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Webhook URL for payment notifications
|
|
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 PSE top-up
|
|
22
|
+
*/
|
|
23
|
+
export interface DepositInformation {
|
|
24
|
+
/**
|
|
25
|
+
* Account URN where funds will be deposited
|
|
26
|
+
* @example "did:bloque:account:card:usr-xxx:crd-xxx"
|
|
30
27
|
*/
|
|
31
|
-
|
|
28
|
+
urn: string;
|
|
32
29
|
}
|
|
33
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Customer data for PSE payment
|
|
32
|
+
*/
|
|
33
|
+
export interface PseCustomerData {
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Customer's full name
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
fullName: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* PSE payment arguments for auto-execution
|
|
41
|
+
*/
|
|
42
|
+
export interface PsePaymentArgs {
|
|
38
43
|
/**
|
|
39
|
-
*
|
|
44
|
+
* Bank code from PSE banks list
|
|
40
45
|
*/
|
|
41
|
-
|
|
46
|
+
bankCode: string;
|
|
42
47
|
/**
|
|
43
|
-
*
|
|
48
|
+
* User type: 'natural' for natural person, 'juridica' for legal entity
|
|
44
49
|
*/
|
|
45
|
-
|
|
50
|
+
userType?: 'natural' | 'juridica';
|
|
46
51
|
/**
|
|
47
|
-
*
|
|
52
|
+
* Customer email address
|
|
48
53
|
*/
|
|
49
|
-
|
|
54
|
+
customerEmail?: string;
|
|
50
55
|
/**
|
|
51
|
-
*
|
|
56
|
+
* User legal ID type (e.g., 'CC', 'NIT', 'CE')
|
|
52
57
|
*/
|
|
53
|
-
|
|
58
|
+
userLegalIdType?: 'CC' | 'NIT' | 'CE';
|
|
54
59
|
/**
|
|
55
|
-
*
|
|
60
|
+
* User legal ID number
|
|
56
61
|
*/
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
export interface PaymentSummary {
|
|
62
|
+
userLegalId?: string;
|
|
60
63
|
/**
|
|
61
|
-
*
|
|
64
|
+
* Additional customer data
|
|
62
65
|
*/
|
|
63
|
-
|
|
66
|
+
customerData?: PseCustomerData;
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Parameters for creating a PSE swap order
|
|
70
|
+
*/
|
|
71
|
+
export interface CreatePseOrderParams {
|
|
66
72
|
/**
|
|
67
|
-
*
|
|
73
|
+
* Rate signature from findRates
|
|
68
74
|
*/
|
|
69
|
-
|
|
75
|
+
rateSig: string;
|
|
70
76
|
/**
|
|
71
|
-
*
|
|
77
|
+
* Destination medium (e.g., 'kreivo', 'bloque')
|
|
72
78
|
*/
|
|
73
|
-
|
|
79
|
+
toMedium: string;
|
|
74
80
|
/**
|
|
75
|
-
*
|
|
81
|
+
* Source amount as bigint string (required if type is 'src')
|
|
82
|
+
* @example "1000000" represents 10000.00 for COP/2
|
|
76
83
|
*/
|
|
77
|
-
|
|
84
|
+
amountSrc?: string;
|
|
78
85
|
/**
|
|
79
|
-
*
|
|
86
|
+
* Destination amount as bigint string (required if type is 'dst')
|
|
80
87
|
*/
|
|
81
|
-
|
|
88
|
+
amountDst?: string;
|
|
82
89
|
/**
|
|
83
|
-
*
|
|
90
|
+
* Order type (default: 'src')
|
|
84
91
|
*/
|
|
85
|
-
|
|
92
|
+
type?: OrderType;
|
|
86
93
|
/**
|
|
87
|
-
*
|
|
94
|
+
* Deposit information with the account URN where funds will be deposited
|
|
88
95
|
*/
|
|
89
|
-
|
|
96
|
+
depositInformation: DepositInformation;
|
|
90
97
|
/**
|
|
91
|
-
*
|
|
98
|
+
* PSE payment arguments for auto-execution
|
|
92
99
|
*/
|
|
93
|
-
|
|
100
|
+
args?: PsePaymentArgs;
|
|
94
101
|
/**
|
|
95
|
-
*
|
|
102
|
+
* Specific node ID to execute (defaults to first node)
|
|
96
103
|
*/
|
|
97
|
-
|
|
104
|
+
nodeId?: string;
|
|
98
105
|
/**
|
|
99
|
-
*
|
|
100
|
-
*/
|
|
101
|
-
cancelUrl?: string;
|
|
102
|
-
/**
|
|
103
|
-
* Payment image URL
|
|
104
|
-
*/
|
|
105
|
-
imageUrl?: string;
|
|
106
|
-
/**
|
|
107
|
-
* Additional metadata
|
|
106
|
+
* Additional metadata for the order
|
|
108
107
|
*/
|
|
109
108
|
metadata?: Record<string, unknown>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Swap order details
|
|
112
|
+
*/
|
|
113
|
+
export interface SwapOrder {
|
|
110
114
|
/**
|
|
111
|
-
*
|
|
115
|
+
* Unique order identifier
|
|
112
116
|
*/
|
|
113
|
-
|
|
117
|
+
id: string;
|
|
114
118
|
/**
|
|
115
|
-
*
|
|
119
|
+
* Order signature
|
|
116
120
|
*/
|
|
117
|
-
|
|
121
|
+
orderSig: string;
|
|
118
122
|
/**
|
|
119
|
-
*
|
|
123
|
+
* Rate signature used for this order
|
|
120
124
|
*/
|
|
121
|
-
|
|
125
|
+
rateSig: string;
|
|
122
126
|
/**
|
|
123
|
-
*
|
|
127
|
+
* Swap signature
|
|
124
128
|
*/
|
|
125
|
-
|
|
129
|
+
swapSig: string;
|
|
126
130
|
/**
|
|
127
|
-
*
|
|
131
|
+
* Taker URN
|
|
128
132
|
*/
|
|
129
|
-
|
|
133
|
+
taker: string;
|
|
130
134
|
/**
|
|
131
|
-
*
|
|
135
|
+
* Maker URN
|
|
132
136
|
*/
|
|
133
|
-
|
|
137
|
+
maker: string;
|
|
134
138
|
/**
|
|
135
|
-
*
|
|
139
|
+
* Source asset
|
|
136
140
|
*/
|
|
137
|
-
|
|
141
|
+
fromAsset: string;
|
|
138
142
|
/**
|
|
139
|
-
*
|
|
143
|
+
* Destination asset
|
|
140
144
|
*/
|
|
141
|
-
|
|
145
|
+
toAsset: string;
|
|
142
146
|
/**
|
|
143
|
-
*
|
|
147
|
+
* Source medium
|
|
144
148
|
*/
|
|
145
|
-
|
|
149
|
+
fromMedium: string;
|
|
146
150
|
/**
|
|
147
|
-
*
|
|
151
|
+
* Destination medium
|
|
148
152
|
*/
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
export interface CreateTopUpResult {
|
|
152
|
-
payment: Payment;
|
|
153
|
-
}
|
|
154
|
-
export interface PsePayee {
|
|
153
|
+
toMedium: string;
|
|
155
154
|
/**
|
|
156
|
-
*
|
|
155
|
+
* Source amount
|
|
157
156
|
*/
|
|
158
|
-
|
|
157
|
+
fromAmount: string;
|
|
159
158
|
/**
|
|
160
|
-
*
|
|
159
|
+
* Destination amount
|
|
161
160
|
*/
|
|
162
|
-
|
|
161
|
+
toAmount: string;
|
|
163
162
|
/**
|
|
164
|
-
*
|
|
163
|
+
* Timestamp when the order was created (as string)
|
|
165
164
|
*/
|
|
166
|
-
|
|
165
|
+
at: string;
|
|
167
166
|
/**
|
|
168
|
-
* ID
|
|
167
|
+
* Instruction graph ID for tracking execution
|
|
169
168
|
*/
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
export type PersonType = 'natural' | 'juridica';
|
|
173
|
-
export interface InitiatePsePaymentParams {
|
|
169
|
+
graphId: string;
|
|
174
170
|
/**
|
|
175
|
-
*
|
|
171
|
+
* Order status (pending, in_progress, completed, failed)
|
|
176
172
|
*/
|
|
177
|
-
|
|
173
|
+
status: string;
|
|
178
174
|
/**
|
|
179
|
-
*
|
|
175
|
+
* Additional metadata
|
|
180
176
|
*/
|
|
181
|
-
|
|
177
|
+
metadata?: Record<string, unknown>;
|
|
182
178
|
/**
|
|
183
|
-
*
|
|
179
|
+
* Creation timestamp
|
|
184
180
|
*/
|
|
185
|
-
|
|
181
|
+
createdAt: string;
|
|
186
182
|
/**
|
|
187
|
-
*
|
|
183
|
+
* Last update timestamp
|
|
188
184
|
*/
|
|
189
|
-
|
|
185
|
+
updatedAt: string;
|
|
190
186
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
paymentId: string;
|
|
196
|
-
/**
|
|
197
|
-
* Payment status
|
|
198
|
-
*/
|
|
199
|
-
status: string;
|
|
187
|
+
/**
|
|
188
|
+
* Redirect instructions for completing the payment
|
|
189
|
+
*/
|
|
190
|
+
export interface ExecutionHow {
|
|
200
191
|
/**
|
|
201
|
-
*
|
|
192
|
+
* Type of action required (e.g., "REDIRECT")
|
|
202
193
|
*/
|
|
203
|
-
|
|
194
|
+
type: string;
|
|
204
195
|
/**
|
|
205
|
-
*
|
|
196
|
+
* URL to redirect the user to complete the payment
|
|
206
197
|
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
198
|
+
url: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Execution result from auto-execution
|
|
202
|
+
*/
|
|
203
|
+
export interface ExecutionResult {
|
|
204
|
+
/**
|
|
205
|
+
* Node ID that was executed
|
|
206
|
+
*/
|
|
207
|
+
nodeId: string;
|
|
208
|
+
/**
|
|
209
|
+
* Execution result details
|
|
210
|
+
*/
|
|
211
|
+
result: {
|
|
212
|
+
/**
|
|
213
|
+
* Execution status (e.g., "paused")
|
|
214
|
+
*/
|
|
215
|
+
status: string;
|
|
216
|
+
/**
|
|
217
|
+
* Name of the current step
|
|
218
|
+
*/
|
|
219
|
+
name?: string;
|
|
220
|
+
/**
|
|
221
|
+
* Description of what the user needs to do
|
|
222
|
+
*/
|
|
223
|
+
description?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Instructions for completing this step
|
|
226
|
+
*/
|
|
227
|
+
how?: ExecutionHow;
|
|
228
|
+
/**
|
|
229
|
+
* Callback token for tracking
|
|
230
|
+
*/
|
|
231
|
+
callbackToken?: string;
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Result of creating a PSE swap order
|
|
236
|
+
*/
|
|
237
|
+
export interface CreatePseOrderResult {
|
|
216
238
|
/**
|
|
217
|
-
*
|
|
239
|
+
* The created order
|
|
218
240
|
*/
|
|
219
|
-
|
|
241
|
+
order: SwapOrder;
|
|
220
242
|
/**
|
|
221
|
-
*
|
|
243
|
+
* Execution result (if args were provided for auto-execution)
|
|
222
244
|
*/
|
|
223
|
-
|
|
245
|
+
execution?: ExecutionResult;
|
|
224
246
|
/**
|
|
225
|
-
*
|
|
247
|
+
* Request ID for tracking
|
|
226
248
|
*/
|
|
227
|
-
|
|
249
|
+
requestId: string;
|
|
228
250
|
}
|
|
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.32",
|
|
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.32"
|
|
38
38
|
}
|
|
39
39
|
}
|