@bloque/sdk-swap 0.8.1 → 0.9.0
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/bank-transfer/bank-transfer-client.d.ts +1 -1
- package/dist/bank-transfer/types.d.ts +36 -4
- package/dist/breb/breb-client.d.ts +4 -1
- package/dist/breb/types.d.ts +29 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/internal/wire-types.d.ts +37 -3
- package/package.json +2 -2
|
@@ -20,7 +20,7 @@ import type { CreateBankTransferOrderOptions, CreateBankTransferOrderParams, Cre
|
|
|
20
20
|
* bankAccountHolderIdentificationType: 'CC',
|
|
21
21
|
* bankAccountHolderIdentificationValue: '1234567890',
|
|
22
22
|
* },
|
|
23
|
-
* args: {
|
|
23
|
+
* args: { sourceAccountUrn: 'did:bloque:card:abc123' },
|
|
24
24
|
* },
|
|
25
25
|
* { idempotencyKey: 'bank-transfer-5000000' }
|
|
26
26
|
* );
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* toMedium: 'banco_de_bogota',
|
|
35
35
|
* amountSrc: '2000000',
|
|
36
36
|
* depositInformation: {
|
|
37
|
-
* bankAccountType: '
|
|
37
|
+
* bankAccountType: 'checkings',
|
|
38
38
|
* bankAccountNumber: '987654321',
|
|
39
39
|
* bankAccountHolderName: 'María López',
|
|
40
40
|
* bankAccountHolderIdentificationType: 'CE',
|
|
@@ -70,11 +70,11 @@ export type SupportedBank = 'banco_agrario_de_colombia' | 'banco_av_villas' | 'b
|
|
|
70
70
|
/**
|
|
71
71
|
* Bank account type
|
|
72
72
|
*/
|
|
73
|
-
export type BankAccountType = 'savings' | '
|
|
73
|
+
export type BankAccountType = 'savings' | 'checkings';
|
|
74
74
|
/**
|
|
75
75
|
* Identification type for account holder
|
|
76
76
|
*/
|
|
77
|
-
export type IdentificationType = 'CC' | 'CE' | 'NIT' | '
|
|
77
|
+
export type IdentificationType = 'CC' | 'CE' | 'NIT' | 'PASSPORT';
|
|
78
78
|
/**
|
|
79
79
|
* Bank deposit information for direct bank transfers
|
|
80
80
|
*
|
|
@@ -234,6 +234,38 @@ export interface ExecutionHowRedirect {
|
|
|
234
234
|
/** URL to redirect the user to complete the payment */
|
|
235
235
|
url: string;
|
|
236
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* A single argument the caller must supply to resume this paused execution
|
|
239
|
+
* via a follow-up call using `callbackToken`.
|
|
240
|
+
*/
|
|
241
|
+
export interface ExecutionCallbackArg {
|
|
242
|
+
/** Argument name */
|
|
243
|
+
name: string;
|
|
244
|
+
/** Expected value type */
|
|
245
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'json';
|
|
246
|
+
/** Default value, if any */
|
|
247
|
+
default?: unknown;
|
|
248
|
+
/** Whether this argument is required to resume execution */
|
|
249
|
+
required: boolean;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Out-of-band completion: an async step (e.g. an eligibility check) is
|
|
253
|
+
* still running. Resume execution later by calling back with the listed
|
|
254
|
+
* `args` and the paused step's `callbackToken`.
|
|
255
|
+
*/
|
|
256
|
+
export interface ExecutionHowCallback {
|
|
257
|
+
type: 'CALLBACK';
|
|
258
|
+
/** Arguments required to resume execution */
|
|
259
|
+
args: ExecutionCallbackArg[];
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* The payment must be completed inside an embedded iframe.
|
|
263
|
+
*/
|
|
264
|
+
export interface ExecutionHowIframe {
|
|
265
|
+
type: 'IFRAME';
|
|
266
|
+
/** URL to load in an iframe to complete the payment */
|
|
267
|
+
iframe: string;
|
|
268
|
+
}
|
|
237
269
|
/**
|
|
238
270
|
* BRE-B on-ramp deposit instructions returned when the graph pauses.
|
|
239
271
|
* Show `keyType` / `keyValue` so the payer can send COP via their bank's BRE-B app.
|
|
@@ -264,7 +296,7 @@ export interface ExecutionHowBrebDeposit {
|
|
|
264
296
|
/**
|
|
265
297
|
* Instructions for completing a paused execution step
|
|
266
298
|
*/
|
|
267
|
-
export type ExecutionHow = ExecutionHowRedirect | ExecutionHowBrebDeposit;
|
|
299
|
+
export type ExecutionHow = ExecutionHowRedirect | ExecutionHowCallback | ExecutionHowIframe | ExecutionHowBrebDeposit;
|
|
268
300
|
/**
|
|
269
301
|
* Execution result from auto-execution
|
|
270
302
|
*/
|
|
@@ -2,7 +2,10 @@ import { BaseClient } from '@bloque/sdk-core';
|
|
|
2
2
|
import type { CreateBrebDepositOptions, CreateBrebDepositParams, CreateBrebDepositResult, CreateBrebOrderOptions, CreateBrebOrderParams, CreateBrebOrderResult } from './types';
|
|
3
3
|
export declare class BrebClient extends BaseClient {
|
|
4
4
|
/**
|
|
5
|
-
* Create a BRE-B payout order (Kusama → BRE-B COP cash-out).
|
|
5
|
+
* Create a BRE-B payout order (Kusama → BRE-B COP cash-out). Converts
|
|
6
|
+
* `params.args.sourceAccountUrn`'s own Kusama balance and pays it out to
|
|
7
|
+
* `params.depositInformation.destinationKey` — any valid BRE-B key,
|
|
8
|
+
* independent of the source account.
|
|
6
9
|
*/
|
|
7
10
|
create(params: CreateBrebOrderParams, options?: CreateBrebOrderOptions): Promise<CreateBrebOrderResult>;
|
|
8
11
|
/**
|
package/dist/breb/types.d.ts
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../bank-transfer/types';
|
|
2
2
|
export type { ExecutionHow, ExecutionResult, OrderType, SwapOrder };
|
|
3
|
+
/**
|
|
4
|
+
* Identifies the payout's recipient by their BRE-B key — any valid key on
|
|
5
|
+
* the network, whether or not it corresponds to a Bloque-managed account.
|
|
6
|
+
*/
|
|
7
|
+
export interface BrebDestinationKey {
|
|
8
|
+
/** The recipient's BRE-B key value, e.g. `'@JAR1234'`. */
|
|
9
|
+
keyValue: string;
|
|
10
|
+
/** The recipient key's type. */
|
|
11
|
+
keyType: 'ID' | 'PHONE' | 'MOBILE' | 'EMAIL' | 'ALPHA' | 'BCODE';
|
|
12
|
+
/** Optional display name for the recipient. */
|
|
13
|
+
displayName?: string;
|
|
14
|
+
}
|
|
3
15
|
export interface BrebDepositInformation {
|
|
4
16
|
/**
|
|
5
|
-
*
|
|
17
|
+
* Any unique string identifying this payout. With the active provider
|
|
18
|
+
* (Cobre), this is used only to derive an idempotency key — it is *not* a
|
|
19
|
+
* real resolution from `session.accounts.breb.resolveKey()`, which is
|
|
20
|
+
* unsupported for Cobre (fails with `E_COBRE_RESOLVE_KEY_UNSUPPORTED`).
|
|
21
|
+
* There is no need to resolve the recipient key before calling
|
|
22
|
+
* `session.swap.breb.create()` — pass any unique value here, e.g. your
|
|
23
|
+
* own order/idempotency id.
|
|
6
24
|
*/
|
|
7
25
|
resolutionId: string;
|
|
26
|
+
/**
|
|
27
|
+
* The recipient of this payout. Required — any valid Bre-B key, whether
|
|
28
|
+
* or not it corresponds to a Bloque-managed account. Independent of
|
|
29
|
+
* `args.sourceAccountUrn`, which only identifies the account being
|
|
30
|
+
* debited on-chain to fund the payout.
|
|
31
|
+
*/
|
|
32
|
+
destinationKey: BrebDestinationKey;
|
|
8
33
|
}
|
|
9
34
|
/**
|
|
10
35
|
* Deposit information for BRE-B on-ramp (COP deposit → Kusama credit).
|
|
@@ -17,7 +42,9 @@ export interface BrebDepositOnRampInformation {
|
|
|
17
42
|
}
|
|
18
43
|
export interface BrebSwapArgs {
|
|
19
44
|
/**
|
|
20
|
-
*
|
|
45
|
+
* Your own Kusama-linked BRE-B account URN — funds the payout (this
|
|
46
|
+
* account's on-chain balance is debited). Not the recipient; see
|
|
47
|
+
* `depositInformation.destinationKey` for that.
|
|
21
48
|
*/
|
|
22
49
|
sourceAccountUrn: string;
|
|
23
50
|
}
|
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,ExternalUsBankSwapClient:()=>ExternalUsBankSwapClient,RtpClient:()=>RtpClient,SwapClient:()=>SwapClient,BankTransferClient:()=>BankTransferClient,BrebClient:()=>BrebClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");function isWireBrebDepositHow(e){return"BREB_DEPOSIT"===e.type}function mapExecutionHow(e){return isWireBrebDepositHow(e)?{type:"BREB_DEPOSIT",medium:e.medium,keyType:e.key_type,keyValue:e.key_value,amount:e.amount,currency:e.currency,reference:e.reference,depositAccountUrn:e.deposit_account_urn,expectedAmount:e.expected_amount,receivedAmount:e.received_amount,remainingAmount:e.remaining_amount,depositStatus:e.deposit_status}:{type:e.type,url:e.url??""}}class BankTransferClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.args&&(o.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class BrebClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapPayoutDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}async createDeposit(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"breb",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{urn:e.depositInformation.urn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),void 0!==e.args&&(o.args=e.args),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId}}_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?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class ExternalUsBankSwapClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"external-us-bank",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{ledger_account_id:e.depositInformation.ledgerAccountId},args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?mapExecutionHow(e.result.how):void 0,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,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.args&&(o.args={bank_code:e.args.bankCode,user_type:e.args.userType,customer_email:e.args.customerEmail,user_legal_id_type:e.args.userLegalIdType,user_legal_id:e.args.userLegalId,redirect_url:e.args.redirectUrl,...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});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?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class RtpClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"rtp",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});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{owner:e.owner,account_number:e.accountNumber,routing_number:e.routingNumber,account_type:e.accountType,...e.bankName&&{bank_name:e.bankName}}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;bankTransfer;breb;rtp;externalUsBank;constructor(e){super(e),this.pse=new PseClient(this.httpClient),this.bankTransfer=new BankTransferClient(this.httpClient),this.breb=new BrebClient(this.httpClient),this.rtp=new RtpClient(this.httpClient),this.externalUsBank=new ExternalUsBankSwapClient(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))}}async listOrders(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=new URLSearchParams;e.orderSig&&a.set("order_sig",e.orderSig),e.swapSig&&a.set("swap_sig",e.swapSig),e.rateSig&&a.set("rate_sig",e.rateSig),e.makerUrn&&a.set("maker_urn",e.makerUrn),e.status&&a.set("status",e.status),e.graphId&&a.set("graph_id",e.graphId),void 0!==e.after&&a.set("after",e.after.toString()),void 0!==e.before&&a.set("before",e.before.toString());let r=a.toString(),o=`/api/order/taker/${t}${r?`?${r}`:""}`;return{orders:(await this.httpClient.request({method:"GET",path:o})).orders.map(e=>this._mapOrderResponse(e))}}async cancelSubscription(e){let t=await this.httpClient.request({method:"POST",path:`/api/order/${e.orderId}/cancel-subscription`});return{status:t.result.status,cursor:t.result.cursor,orderId:t.result.order_id,graphId:t.result.graph_id}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_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.BrebClient=__webpack_exports__.BrebClient,exports.ExternalUsBankSwapClient=__webpack_exports__.ExternalUsBankSwapClient,exports.PseClient=__webpack_exports__.PseClient,exports.RtpClient=__webpack_exports__.RtpClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["BankTransferClient","BrebClient","ExternalUsBankSwapClient","PseClient","RtpClient","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__,{PseClient:()=>PseClient,ExternalUsBankSwapClient:()=>ExternalUsBankSwapClient,RtpClient:()=>RtpClient,SwapClient:()=>SwapClient,BankTransferClient:()=>BankTransferClient,BrebClient:()=>BrebClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");function isWireBrebDepositHow(e){return"BREB_DEPOSIT"===e.type}function isWireCallbackHow(e){return"CALLBACK"===e.type&&"args"in e}function isWireIframeHow(e){return"IFRAME"===e.type&&"iframe"in e}function mapExecutionHow(e){return isWireBrebDepositHow(e)?{type:"BREB_DEPOSIT",medium:e.medium,keyType:e.key_type,keyValue:e.key_value,amount:e.amount,currency:e.currency,reference:e.reference,depositAccountUrn:e.deposit_account_urn,expectedAmount:e.expected_amount,receivedAmount:e.received_amount,remainingAmount:e.remaining_amount,depositStatus:e.deposit_status}:isWireCallbackHow(e)?{type:"CALLBACK",args:e.args}:isWireIframeHow(e)?{type:"IFRAME",iframe:e.iframe}:{type:e.type,url:e.url??""}}class BankTransferClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.args&&(o.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class BrebClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapPayoutDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}async createDeposit(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"breb",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{urn:e.depositInformation.urn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),void 0!==e.args&&(o.args=e.args),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId,destination_key:{key_value:e.destinationKey.keyValue,key_type:e.destinationKey.keyType,...e.destinationKey.displayName?{display_name:e.destinationKey.displayName}:{}}}}_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?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class ExternalUsBankSwapClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"external-us-bank",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{ledger_account_id:e.depositInformation.ledgerAccountId},args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?mapExecutionHow(e.result.how):void 0,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,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.args&&(o.args={bank_code:e.args.bankCode,user_type:e.args.userType,customer_email:e.args.customerEmail,user_legal_id_type:e.args.userLegalIdType,user_legal_id:e.args.userLegalId,redirect_url:e.args.redirectUrl,...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});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?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class RtpClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"rtp",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});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{owner:e.owner,account_number:e.accountNumber,routing_number:e.routingNumber,account_type:e.accountType,...e.bankName&&{bank_name:e.bankName}}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;bankTransfer;breb;rtp;externalUsBank;constructor(e){super(e),this.pse=new PseClient(this.httpClient),this.bankTransfer=new BankTransferClient(this.httpClient),this.breb=new BrebClient(this.httpClient),this.rtp=new RtpClient(this.httpClient),this.externalUsBank=new ExternalUsBankSwapClient(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))}}async listOrders(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=new URLSearchParams;e.orderSig&&a.set("order_sig",e.orderSig),e.swapSig&&a.set("swap_sig",e.swapSig),e.rateSig&&a.set("rate_sig",e.rateSig),e.makerUrn&&a.set("maker_urn",e.makerUrn),e.status&&a.set("status",e.status),e.graphId&&a.set("graph_id",e.graphId),void 0!==e.after&&a.set("after",e.after.toString()),void 0!==e.before&&a.set("before",e.before.toString());let r=a.toString(),o=`/api/order/taker/${t}${r?`?${r}`:""}`;return{orders:(await this.httpClient.request({method:"GET",path:o})).orders.map(e=>this._mapOrderResponse(e))}}async cancelSubscription(e){let t=await this.httpClient.request({method:"POST",path:`/api/order/${e.orderId}/cancel-subscription`});return{status:t.result.status,cursor:t.result.cursor,orderId:t.result.order_id,graphId:t.result.graph_id}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_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.BrebClient=__webpack_exports__.BrebClient,exports.ExternalUsBankSwapClient=__webpack_exports__.ExternalUsBankSwapClient,exports.PseClient=__webpack_exports__.PseClient,exports.RtpClient=__webpack_exports__.RtpClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["BankTransferClient","BrebClient","ExternalUsBankSwapClient","PseClient","RtpClient","SwapClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BankTransferClient } from './bank-transfer/bank-transfer-client';
|
|
2
|
-
export type { BankAccountType, BankDepositInformation, CreateBankTransferOrderOptions, CreateBankTransferOrderParams, CreateBankTransferOrderResult, ExecutionHow, ExecutionHowBrebDeposit, ExecutionHowRedirect, ExecutionResult, IdentificationType, KusamaAccountArgs, OrderType, SupportedBank, SwapOrder, } from './bank-transfer/types';
|
|
2
|
+
export type { BankAccountType, BankDepositInformation, CreateBankTransferOrderOptions, CreateBankTransferOrderParams, CreateBankTransferOrderResult, ExecutionCallbackArg, ExecutionHow, ExecutionHowBrebDeposit, ExecutionHowCallback, ExecutionHowIframe, ExecutionHowRedirect, ExecutionResult, IdentificationType, KusamaAccountArgs, OrderType, SupportedBank, SwapOrder, } from './bank-transfer/types';
|
|
3
3
|
export { BrebClient } from './breb/breb-client';
|
|
4
|
-
export type { BrebDepositInformation, BrebDepositOnRampInformation, BrebSwapArgs, CreateBrebDepositOptions, CreateBrebDepositParams, CreateBrebDepositResult, CreateBrebOrderOptions, CreateBrebOrderParams, CreateBrebOrderResult, } from './breb/types';
|
|
4
|
+
export type { BrebDepositInformation, BrebDepositOnRampInformation, BrebDestinationKey, BrebSwapArgs, CreateBrebDepositOptions, CreateBrebDepositParams, CreateBrebDepositResult, CreateBrebOrderOptions, CreateBrebOrderParams, CreateBrebOrderResult, } from './breb/types';
|
|
5
5
|
export { ExternalUsBankSwapClient } from './external-us-bank/external-us-bank-client';
|
|
6
6
|
export type { CreateExternalUsBankOrderOptions, CreateExternalUsBankOrderParams, CreateExternalUsBankOrderResult, ExternalUsBankArgs, ExternalUsBankDepositInformation, } from './external-us-bank/types';
|
|
7
7
|
export { PseClient } from './pse/pse-client';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BaseClient as e,BloqueConfigError as t}from"@bloque/sdk-core";function a(e){return"BREB_DEPOSIT"===e.type?{type:"BREB_DEPOSIT",medium:e.medium,keyType:e.key_type,keyValue:e.key_value,amount:e.amount,currency:e.currency,reference:e.reference,depositAccountUrn:e.deposit_account_urn,expectedAmount:e.expected_amount,receivedAmount:e.received_amount,remainingAmount:e.remaining_amount,depositStatus:e.deposit_status}:{type:e.type,url:e.url??""}}class r extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.args&&(s.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(n.result.order),execution:n.result.execution?this._mapExecutionResult(n.result.execution):void 0,requestId:n.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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class o extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapPayoutDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(n.result.order),execution:n.result.execution?this._mapExecutionResult(n.result.execution):void 0,requestId:n.req_id}}async createDeposit(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"breb",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{urn:e.depositInformation.urn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),void 0!==e.args&&(s.args=e.args),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(n.result.order),execution:n.result.execution?this._mapExecutionResult(n.result.execution):void 0,requestId:n.req_id}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId}}_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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class s extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"external-us-bank",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{ledger_account_id:e.depositInformation.ledgerAccountId},args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(n.result.order),execution:n.result.execution?this._mapExecutionResult(n.result.execution):void 0,requestId:n.req_id}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class n 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,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.args&&(s.args={bank_code:e.args.bankCode,user_type:e.args.userType,customer_email:e.args.customerEmail,user_legal_id_type:e.args.userLegalIdType,user_legal_id:e.args.userLegalId,redirect_url:e.args.redirectUrl,...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(n.result.order),execution:n.result.execution?this._mapExecutionResult(n.result.execution):void 0,requestId:n.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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class i extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"rtp",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(n.result.order),execution:n.result.execution?this._mapExecutionResult(n.result.execution):void 0,requestId:n.req_id}}_mapDepositInformationToWire(e){return{owner:e.owner,account_number:e.accountNumber,routing_number:e.routingNumber,account_type:e.accountType,...e.bankName&&{bank_name:e.bankName}}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class u extends e{pse;bankTransfer;breb;rtp;externalUsBank;constructor(e){super(e),this.pse=new n(this.httpClient),this.bankTransfer=new r(this.httpClient),this.breb=new o(this.httpClient),this.rtp=new i(this.httpClient),this.externalUsBank=new s(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))}}async listOrders(e={}){let a=this.httpClient.urn;if(!a)throw new t("User URN is not available. Please connect to a session first.");let r=new URLSearchParams;e.orderSig&&r.set("order_sig",e.orderSig),e.swapSig&&r.set("swap_sig",e.swapSig),e.rateSig&&r.set("rate_sig",e.rateSig),e.makerUrn&&r.set("maker_urn",e.makerUrn),e.status&&r.set("status",e.status),e.graphId&&r.set("graph_id",e.graphId),void 0!==e.after&&r.set("after",e.after.toString()),void 0!==e.before&&r.set("before",e.before.toString());let o=r.toString(),s=`/api/order/taker/${a}${o?`?${o}`:""}`;return{orders:(await this.httpClient.request({method:"GET",path:s})).orders.map(e=>this._mapOrderResponse(e))}}async cancelSubscription(e){let t=await this.httpClient.request({method:"POST",path:`/api/order/${e.orderId}/cancel-subscription`});return{status:t.result.status,cursor:t.result.cursor,orderId:t.result.order_id,graphId:t.result.graph_id}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_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{r as BankTransferClient,o as BrebClient,s as ExternalUsBankSwapClient,n as PseClient,i as RtpClient,u as SwapClient};
|
|
1
|
+
import{BaseClient as e,BloqueConfigError as t}from"@bloque/sdk-core";function a(e){return"BREB_DEPOSIT"===e.type?{type:"BREB_DEPOSIT",medium:e.medium,keyType:e.key_type,keyValue:e.key_value,amount:e.amount,currency:e.currency,reference:e.reference,depositAccountUrn:e.deposit_account_urn,expectedAmount:e.expected_amount,receivedAmount:e.received_amount,remainingAmount:e.remaining_amount,depositStatus:e.deposit_status}:"CALLBACK"===e.type&&"args"in e?{type:"CALLBACK",args:e.args}:"IFRAME"===e.type&&"iframe"in e?{type:"IFRAME",iframe:e.iframe}:{type:e.type,url:e.url??""}}class r extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.args&&(s.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class o extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapPayoutDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}async createDeposit(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"breb",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{urn:e.depositInformation.urn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),void 0!==e.args&&(s.args=e.args),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId,destination_key:{key_value:e.destinationKey.keyValue,key_type:e.destinationKey.keyType,...e.destinationKey.displayName?{display_name:e.destinationKey.displayName}:{}}}}_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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class s extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"external-us-bank",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{ledger_account_id:e.depositInformation.ledgerAccountId},args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class i 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,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.args&&(s.args={bank_code:e.args.bankCode,user_type:e.args.userType,customer_email:e.args.customerEmail,user_legal_id_type:e.args.userLegalIdType,user_legal_id:e.args.userLegalId,redirect_url:e.args.redirectUrl,...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class n extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"rtp",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapDepositInformationToWire(e){return{owner:e.owner,account_number:e.accountNumber,routing_number:e.routingNumber,account_type:e.accountType,...e.bankName&&{bank_name:e.bankName}}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,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?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class u extends e{pse;bankTransfer;breb;rtp;externalUsBank;constructor(e){super(e),this.pse=new i(this.httpClient),this.bankTransfer=new r(this.httpClient),this.breb=new o(this.httpClient),this.rtp=new n(this.httpClient),this.externalUsBank=new s(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))}}async listOrders(e={}){let a=this.httpClient.urn;if(!a)throw new t("User URN is not available. Please connect to a session first.");let r=new URLSearchParams;e.orderSig&&r.set("order_sig",e.orderSig),e.swapSig&&r.set("swap_sig",e.swapSig),e.rateSig&&r.set("rate_sig",e.rateSig),e.makerUrn&&r.set("maker_urn",e.makerUrn),e.status&&r.set("status",e.status),e.graphId&&r.set("graph_id",e.graphId),void 0!==e.after&&r.set("after",e.after.toString()),void 0!==e.before&&r.set("before",e.before.toString());let o=r.toString(),s=`/api/order/taker/${a}${o?`?${o}`:""}`;return{orders:(await this.httpClient.request({method:"GET",path:s})).orders.map(e=>this._mapOrderResponse(e))}}async cancelSubscription(e){let t=await this.httpClient.request({method:"POST",path:`/api/order/${e.orderId}/cancel-subscription`});return{status:t.result.status,cursor:t.result.cursor,orderId:t.result.order_id,graphId:t.result.graph_id}}_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,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_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{r as BankTransferClient,o as BrebClient,s as ExternalUsBankSwapClient,i as PseClient,n as RtpClient,u as SwapClient};
|
|
@@ -82,6 +82,12 @@ export interface DepositInformation {
|
|
|
82
82
|
urn?: string;
|
|
83
83
|
/** BRE-B payout resolution id */
|
|
84
84
|
resolution_id?: string;
|
|
85
|
+
/** BRE-B payout recipient, identified by their key */
|
|
86
|
+
destination_key?: {
|
|
87
|
+
key_value: string;
|
|
88
|
+
key_type: string;
|
|
89
|
+
display_name?: string;
|
|
90
|
+
};
|
|
85
91
|
/** External US bank on-ramp: destination Kusama ledger account id */
|
|
86
92
|
ledger_account_id?: string;
|
|
87
93
|
/** RTP payout: account holder name */
|
|
@@ -102,10 +108,10 @@ export interface DepositInformation {
|
|
|
102
108
|
* Bancolombia deposit information for bank account details
|
|
103
109
|
*/
|
|
104
110
|
export interface BancolombiaDepositInformation {
|
|
105
|
-
bank_account_type: 'savings' | '
|
|
111
|
+
bank_account_type: 'savings' | 'checkings';
|
|
106
112
|
bank_account_number: string;
|
|
107
113
|
bank_account_holder_name: string;
|
|
108
|
-
bank_account_holder_identification_type: 'CC' | 'CE' | 'NIT' | '
|
|
114
|
+
bank_account_holder_identification_type: 'CC' | 'CE' | 'NIT' | 'PASSPORT';
|
|
109
115
|
bank_account_holder_identification_value: string;
|
|
110
116
|
}
|
|
111
117
|
/**
|
|
@@ -168,6 +174,34 @@ export interface ExecutionHowRedirect {
|
|
|
168
174
|
type: string;
|
|
169
175
|
url?: string;
|
|
170
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* @internal
|
|
179
|
+
* A single argument the caller must supply to resume a paused execution
|
|
180
|
+
* via a follow-up call using `callback_token`.
|
|
181
|
+
*/
|
|
182
|
+
export interface ExecutionCallbackArg {
|
|
183
|
+
name: string;
|
|
184
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'json';
|
|
185
|
+
default?: unknown;
|
|
186
|
+
required: boolean;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @internal
|
|
190
|
+
* Out-of-band completion: the caller must resume execution later (e.g. once
|
|
191
|
+
* an async eligibility check completes) by supplying the listed args.
|
|
192
|
+
*/
|
|
193
|
+
export interface ExecutionHowCallback {
|
|
194
|
+
type: 'CALLBACK';
|
|
195
|
+
args: ExecutionCallbackArg[];
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @internal
|
|
199
|
+
* The payment must be completed inside an embedded iframe.
|
|
200
|
+
*/
|
|
201
|
+
export interface ExecutionHowIframe {
|
|
202
|
+
type: 'IFRAME';
|
|
203
|
+
iframe: string;
|
|
204
|
+
}
|
|
171
205
|
/**
|
|
172
206
|
* @internal
|
|
173
207
|
* BRE-B on-ramp deposit instructions returned when the graph pauses
|
|
@@ -194,7 +228,7 @@ export interface ExecutionHowBrebDeposit {
|
|
|
194
228
|
* @internal
|
|
195
229
|
* Discriminated union of execution instructions
|
|
196
230
|
*/
|
|
197
|
-
export type ExecutionHow = ExecutionHowRedirect | ExecutionHowBrebDeposit;
|
|
231
|
+
export type ExecutionHow = ExecutionHowRedirect | ExecutionHowCallback | ExecutionHowIframe | ExecutionHowBrebDeposit;
|
|
198
232
|
/**
|
|
199
233
|
* @internal
|
|
200
234
|
* Execution result from auto-execution
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-swap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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.
|
|
37
|
+
"@bloque/sdk-core": "0.9.0"
|
|
38
38
|
}
|
|
39
39
|
}
|