@bloque/sdk-swap 0.0.31 → 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 +16 -21
- package/dist/pse/pse-client.d.ts +17 -11
- package/dist/pse/types.d.ts +62 -28
- 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 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
|
|
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,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
|
|
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};
|
|
@@ -75,25 +75,11 @@ export interface ListPseBanksResponse {
|
|
|
75
75
|
export type OrderType = 'src' | 'dst';
|
|
76
76
|
/**
|
|
77
77
|
* @internal
|
|
78
|
-
* Deposit information for
|
|
78
|
+
* Deposit information for PSE top-up
|
|
79
79
|
*/
|
|
80
|
-
export interface
|
|
81
|
-
|
|
80
|
+
export interface DepositInformation {
|
|
81
|
+
urn: string;
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
84
|
-
* @internal
|
|
85
|
-
* Deposit information for cash-out (crypto to fiat)
|
|
86
|
-
*/
|
|
87
|
-
export interface DepositInformationCashOut {
|
|
88
|
-
bank_code?: string;
|
|
89
|
-
account_number?: string;
|
|
90
|
-
account_type?: string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* @internal
|
|
94
|
-
* Deposit information union type
|
|
95
|
-
*/
|
|
96
|
-
export type DepositInformation = DepositInformationCashIn | DepositInformationCashOut | Record<string, unknown>;
|
|
97
83
|
/**
|
|
98
84
|
* @internal
|
|
99
85
|
* Create order input for PUT /api/order
|
|
@@ -128,13 +114,21 @@ export interface OrderResponse {
|
|
|
128
114
|
to_medium: string;
|
|
129
115
|
from_amount: string;
|
|
130
116
|
to_amount: string;
|
|
131
|
-
|
|
132
|
-
at: number;
|
|
117
|
+
at: string;
|
|
133
118
|
graph_id: string;
|
|
134
119
|
status: string;
|
|
120
|
+
metadata?: Record<string, unknown>;
|
|
135
121
|
created_at: string;
|
|
136
122
|
updated_at: string;
|
|
137
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* @internal
|
|
126
|
+
* Execution redirect instructions
|
|
127
|
+
*/
|
|
128
|
+
export interface ExecutionHow {
|
|
129
|
+
type: string;
|
|
130
|
+
url: string;
|
|
131
|
+
}
|
|
138
132
|
/**
|
|
139
133
|
* @internal
|
|
140
134
|
* Execution result from auto-execution
|
|
@@ -143,9 +137,10 @@ export interface ExecutionResult {
|
|
|
143
137
|
node_id: string;
|
|
144
138
|
result: {
|
|
145
139
|
status: string;
|
|
146
|
-
|
|
140
|
+
name?: string;
|
|
147
141
|
description?: string;
|
|
148
|
-
|
|
142
|
+
how?: ExecutionHow;
|
|
143
|
+
callback_token?: string;
|
|
149
144
|
};
|
|
150
145
|
}
|
|
151
146
|
/**
|
package/dist/pse/pse-client.d.ts
CHANGED
|
@@ -39,17 +39,28 @@ export declare class PseClient extends BaseClient {
|
|
|
39
39
|
* fromAsset: 'COP/2',
|
|
40
40
|
* toAsset: 'DUSD/6',
|
|
41
41
|
* fromMediums: ['pse'],
|
|
42
|
-
* toMediums: ['
|
|
43
|
-
* amountSrc: '
|
|
42
|
+
* toMediums: ['kusama'],
|
|
43
|
+
* amountSrc: '10000000'
|
|
44
44
|
* });
|
|
45
45
|
*
|
|
46
46
|
* // Create order with auto-execution
|
|
47
47
|
* const result = await bloque.swap.pse.create({
|
|
48
48
|
* rateSig: rates.rates[0].sig,
|
|
49
|
-
* toMedium: '
|
|
50
|
-
* amountSrc: '
|
|
51
|
-
* depositInformation: {
|
|
52
|
-
*
|
|
49
|
+
* toMedium: 'kusama',
|
|
50
|
+
* amountSrc: '10000000',
|
|
51
|
+
* depositInformation: {
|
|
52
|
+
* urn: 'did:bloque:account:card:usr-xxx:crd-xxx'
|
|
53
|
+
* },
|
|
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
|
+
* }
|
|
53
64
|
* });
|
|
54
65
|
*
|
|
55
66
|
* // If execution returned a checkout URL, redirect user
|
|
@@ -69,11 +80,6 @@ export declare class PseClient extends BaseClient {
|
|
|
69
80
|
* @internal
|
|
70
81
|
*/
|
|
71
82
|
private _mapDepositInformationToWire;
|
|
72
|
-
/**
|
|
73
|
-
* Maps wire deposit information to SDK format
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
private _mapDepositInformationFromWire;
|
|
77
83
|
/**
|
|
78
84
|
* Maps API order response to SDK format
|
|
79
85
|
* @internal
|
package/dist/pse/types.d.ts
CHANGED
|
@@ -18,23 +18,24 @@ export interface ListBanksResult {
|
|
|
18
18
|
*/
|
|
19
19
|
export type OrderType = 'src' | 'dst';
|
|
20
20
|
/**
|
|
21
|
-
* Deposit information for
|
|
21
|
+
* Deposit information for PSE top-up
|
|
22
22
|
*/
|
|
23
|
-
export interface
|
|
24
|
-
|
|
23
|
+
export interface DepositInformation {
|
|
24
|
+
/**
|
|
25
|
+
* Account URN where funds will be deposited
|
|
26
|
+
* @example "did:bloque:account:card:usr-xxx:crd-xxx"
|
|
27
|
+
*/
|
|
28
|
+
urn: string;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Customer data for PSE payment
|
|
28
32
|
*/
|
|
29
|
-
export interface
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
export interface PseCustomerData {
|
|
34
|
+
/**
|
|
35
|
+
* Customer's full name
|
|
36
|
+
*/
|
|
37
|
+
fullName: string;
|
|
33
38
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Deposit information union type
|
|
36
|
-
*/
|
|
37
|
-
export type DepositInformation = DepositInformationCashIn | DepositInformationCashOut | Record<string, unknown>;
|
|
38
39
|
/**
|
|
39
40
|
* PSE payment arguments for auto-execution
|
|
40
41
|
*/
|
|
@@ -44,9 +45,25 @@ export interface PsePaymentArgs {
|
|
|
44
45
|
*/
|
|
45
46
|
bankCode: string;
|
|
46
47
|
/**
|
|
47
|
-
* User type: '
|
|
48
|
+
* User type: 'natural' for natural person, 'juridica' for legal entity
|
|
49
|
+
*/
|
|
50
|
+
userType?: 'natural' | 'juridica';
|
|
51
|
+
/**
|
|
52
|
+
* Customer email address
|
|
48
53
|
*/
|
|
49
|
-
|
|
54
|
+
customerEmail?: string;
|
|
55
|
+
/**
|
|
56
|
+
* User legal ID type (e.g., 'CC', 'NIT', 'CE')
|
|
57
|
+
*/
|
|
58
|
+
userLegalIdType?: 'CC' | 'NIT' | 'CE';
|
|
59
|
+
/**
|
|
60
|
+
* User legal ID number
|
|
61
|
+
*/
|
|
62
|
+
userLegalId?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Additional customer data
|
|
65
|
+
*/
|
|
66
|
+
customerData?: PseCustomerData;
|
|
50
67
|
}
|
|
51
68
|
/**
|
|
52
69
|
* Parameters for creating a PSE swap order
|
|
@@ -74,9 +91,9 @@ export interface CreatePseOrderParams {
|
|
|
74
91
|
*/
|
|
75
92
|
type?: OrderType;
|
|
76
93
|
/**
|
|
77
|
-
* Deposit information
|
|
94
|
+
* Deposit information with the account URN where funds will be deposited
|
|
78
95
|
*/
|
|
79
|
-
depositInformation
|
|
96
|
+
depositInformation: DepositInformation;
|
|
80
97
|
/**
|
|
81
98
|
* PSE payment arguments for auto-execution
|
|
82
99
|
*/
|
|
@@ -143,13 +160,9 @@ export interface SwapOrder {
|
|
|
143
160
|
*/
|
|
144
161
|
toAmount: string;
|
|
145
162
|
/**
|
|
146
|
-
*
|
|
163
|
+
* Timestamp when the order was created (as string)
|
|
147
164
|
*/
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Timestamp when the order was created
|
|
151
|
-
*/
|
|
152
|
-
at: number;
|
|
165
|
+
at: string;
|
|
153
166
|
/**
|
|
154
167
|
* Instruction graph ID for tracking execution
|
|
155
168
|
*/
|
|
@@ -158,6 +171,10 @@ export interface SwapOrder {
|
|
|
158
171
|
* Order status (pending, in_progress, completed, failed)
|
|
159
172
|
*/
|
|
160
173
|
status: string;
|
|
174
|
+
/**
|
|
175
|
+
* Additional metadata
|
|
176
|
+
*/
|
|
177
|
+
metadata?: Record<string, unknown>;
|
|
161
178
|
/**
|
|
162
179
|
* Creation timestamp
|
|
163
180
|
*/
|
|
@@ -167,6 +184,19 @@ export interface SwapOrder {
|
|
|
167
184
|
*/
|
|
168
185
|
updatedAt: string;
|
|
169
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Redirect instructions for completing the payment
|
|
189
|
+
*/
|
|
190
|
+
export interface ExecutionHow {
|
|
191
|
+
/**
|
|
192
|
+
* Type of action required (e.g., "REDIRECT")
|
|
193
|
+
*/
|
|
194
|
+
type: string;
|
|
195
|
+
/**
|
|
196
|
+
* URL to redirect the user to complete the payment
|
|
197
|
+
*/
|
|
198
|
+
url: string;
|
|
199
|
+
}
|
|
170
200
|
/**
|
|
171
201
|
* Execution result from auto-execution
|
|
172
202
|
*/
|
|
@@ -180,21 +210,25 @@ export interface ExecutionResult {
|
|
|
180
210
|
*/
|
|
181
211
|
result: {
|
|
182
212
|
/**
|
|
183
|
-
* Execution status
|
|
213
|
+
* Execution status (e.g., "paused")
|
|
184
214
|
*/
|
|
185
215
|
status: string;
|
|
186
216
|
/**
|
|
187
|
-
*
|
|
217
|
+
* Name of the current step
|
|
188
218
|
*/
|
|
189
|
-
|
|
219
|
+
name?: string;
|
|
190
220
|
/**
|
|
191
|
-
* Description of the
|
|
221
|
+
* Description of what the user needs to do
|
|
192
222
|
*/
|
|
193
223
|
description?: string;
|
|
194
224
|
/**
|
|
195
|
-
*
|
|
225
|
+
* Instructions for completing this step
|
|
226
|
+
*/
|
|
227
|
+
how?: ExecutionHow;
|
|
228
|
+
/**
|
|
229
|
+
* Callback token for tracking
|
|
196
230
|
*/
|
|
197
|
-
|
|
231
|
+
callbackToken?: string;
|
|
198
232
|
};
|
|
199
233
|
}
|
|
200
234
|
/**
|
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
|
}
|