@pakt/psilo 0.0.1 → 0.0.2
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/README.md +98 -61
- package/dist/main.d.ts +6 -51
- package/dist/main.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# PsiloSDK
|
|
2
2
|
|
|
3
|
-
PsiloSDK is the official TypeScript SDK for interacting
|
|
3
|
+
PsiloSDK is the official TypeScript SDK for interacting with Pakt's production-ready EVM escrow service. It provides a typed interface over the Pakt Escrow REST API for creating, managing, and releasing non-custodial escrow wallets deployed via `Psilo-Contracts`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Authentication uses SIWA (Sign In With Agent) — agents authenticate via ERC-8128 HTTP Message Signatures with SIWA receipts.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -14,94 +14,131 @@ yarn add @pakt/psilo-sdk
|
|
|
14
14
|
|
|
15
15
|
## Setup & Initialization
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Initialise the PsiloSDK like so:
|
|
18
|
+
|
|
19
|
+
Development baseUrl: `https://devescrow.psiloai.com`
|
|
20
|
+
|
|
21
|
+
Production baseUrl: `https://escrow.psiloai.com`
|
|
18
22
|
|
|
19
23
|
```typescript
|
|
20
24
|
import { PsiloSDK } from "@pakt/psilo-sdk";
|
|
21
25
|
|
|
22
26
|
const sdk = await PsiloSDK.init({
|
|
23
|
-
baseUrl: "
|
|
24
|
-
verbose: true //
|
|
27
|
+
baseUrl: "https://devescrow.psiloai.com", //for development
|
|
28
|
+
verbose: true // optional logging
|
|
25
29
|
});
|
|
26
30
|
```
|
|
27
31
|
|
|
28
|
-
##
|
|
32
|
+
## Escrow Lifecycle
|
|
33
|
+
|
|
34
|
+
The escrow flow has four phases:
|
|
35
|
+
|
|
36
|
+
1. **Create** — server deploys the escrow contract and returns the address plus unsigned deposit transaction
|
|
37
|
+
2. **Deposit** — buyer signs and broadcasts the deposit transaction client-side
|
|
38
|
+
3. **Mark ready** — seller and buyer each call `updateStatus` to signal readiness; returns an unsigned transaction for each party to sign and send
|
|
39
|
+
4. **Release** — system triggers `release` once both parties have marked ready
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
---
|
|
31
42
|
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
## API Reference
|
|
44
|
+
|
|
45
|
+
### Chains & Assets
|
|
46
|
+
|
|
47
|
+
Discover supported networks and tokens before creating an escrow.
|
|
34
48
|
|
|
35
49
|
```typescript
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
console.log("Predicted address:", computed.data.predictedAddress);
|
|
50
|
+
// List all supported chains
|
|
51
|
+
const { data } = await sdk.escrow.getChains();
|
|
52
|
+
// data.chains: Array<{ chainId, name, network, nativeCurrency }>
|
|
53
|
+
|
|
54
|
+
// List supported assets for a chain
|
|
55
|
+
const { data } = await sdk.escrow.getAssets("43113");
|
|
56
|
+
// data.assets: Array<{ address, symbol, name, decimals, isNative }>
|
|
45
57
|
```
|
|
46
58
|
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### 1. Create Escrow
|
|
62
|
+
|
|
63
|
+
The server calls `EscrowFactory.createEscrow()` using its configured private key and returns the deployed `EscrowWallet` address along with the unsigned deposit transaction for the buyer to send.
|
|
49
64
|
|
|
50
65
|
```typescript
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
const { data } = await sdk.escrow.create({
|
|
67
|
+
chainId: "43113", // EIP-155 chain ID
|
|
68
|
+
buyer: "0xBuyerAddress...",
|
|
69
|
+
seller: "0xSellerAddress...",
|
|
70
|
+
title: "Website redesign",
|
|
71
|
+
description: "Full redesign of landing page", // optional
|
|
72
|
+
amount: "100", // in token units
|
|
73
|
+
asset: "0x5425890298aed601595a70AB815c96711a31Bc65", // token contract address
|
|
74
|
+
expiration: "1735689600", // unix timestamp, optional
|
|
75
|
+
releaseType: "0" // 0–255, optional
|
|
59
76
|
});
|
|
60
|
-
|
|
77
|
+
|
|
78
|
+
const { escrowAddress, approve, deposit } = data.onChain;
|
|
79
|
+
// If asset requires allowance: sign and send `approve` tx first
|
|
80
|
+
// Then sign and send `deposit` tx to fund the escrow
|
|
61
81
|
```
|
|
62
82
|
|
|
63
|
-
|
|
64
|
-
|
|
83
|
+
**Response fields:**
|
|
84
|
+
|
|
85
|
+
| Field | Description |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `onChain.escrowAddress` | Deployed escrow contract address |
|
|
88
|
+
| `onChain.approve` | ERC-20 approve tx to sign/send (null for native tokens) |
|
|
89
|
+
| `onChain.deposit` | Deposit tx to sign/send |
|
|
90
|
+
| `onChain.txHash` | Factory deployment tx hash |
|
|
91
|
+
| `buyerWallet` / `sellerWallet` / `arbiterWallet` | Party addresses |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### 2. Query Status
|
|
65
96
|
|
|
66
97
|
```typescript
|
|
67
|
-
await sdk.escrow.
|
|
68
|
-
|
|
69
|
-
|
|
98
|
+
const { data } = await sdk.escrow.getStatus("43113", "0xEscrowAddress...");
|
|
99
|
+
|
|
100
|
+
console.log(data.deposited); // buyer has funded the escrow
|
|
101
|
+
console.log(data.readyForRelease); // seller has marked ready
|
|
102
|
+
console.log(data.buyerReleaseReady); // buyer has marked ready
|
|
103
|
+
console.log(data.balance); // current balance (wei / smallest unit)
|
|
70
104
|
```
|
|
71
105
|
|
|
72
|
-
|
|
73
|
-
|
|
106
|
+
**Response fields:** `chainId`, `escrow`, `buyer`, `seller`, `arbiter`, `deposited`, `released`, `readyForRelease`, `buyerReleaseReady`, `balance`
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### 3. Mark Ready (Seller & Buyer)
|
|
111
|
+
|
|
112
|
+
Both parties must signal readiness before the escrow can be released. `updateStatus` checks the provided address against the escrow contract and returns the appropriate unsigned transaction:
|
|
113
|
+
|
|
114
|
+
- **Seller address** → `markReady` transaction
|
|
115
|
+
- **Buyer address** → `markBuyerEscrowReleaseReady` transaction
|
|
74
116
|
|
|
75
117
|
```typescript
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// Query all
|
|
81
|
-
const escrows = await sdk.escrow.list({
|
|
82
|
-
sender: "0xSenderAddress...",
|
|
83
|
-
status: "deposited"
|
|
118
|
+
const { data } = await sdk.escrow.updateStatus({
|
|
119
|
+
chainId: "43113",
|
|
120
|
+
escrow: "0xEscrowAddress...",
|
|
121
|
+
address: "0xSellerOrBuyerAddress..."
|
|
84
122
|
});
|
|
123
|
+
|
|
124
|
+
// data is a PrepareTransactionResponse — sign and broadcast it client-side
|
|
125
|
+
// { to, data, value, chainId, gas, maxFeePerGas, maxPriorityFeePerGas, type, nonce, instructions }
|
|
85
126
|
```
|
|
86
127
|
|
|
87
|
-
|
|
88
|
-
The MPC-shard functionality is exposed through signing a release using 2-of-3 configured authority.
|
|
128
|
+
---
|
|
89
129
|
|
|
90
|
-
|
|
91
|
-
// Ask the sender to sign
|
|
92
|
-
const senderSignature = await sdk.escrow.signRelease(escrowAddress, {
|
|
93
|
-
signerAddress: "0xSenderAddress...",
|
|
94
|
-
privateKey: "0x..." // Optional if managed by the MCP server environment
|
|
95
|
-
});
|
|
130
|
+
### 4. Release Escrow
|
|
96
131
|
|
|
97
|
-
|
|
98
|
-
const receiverSignature = await sdk.escrow.signRelease(escrowAddress, {
|
|
99
|
-
signerAddress: "0xReceiverAddress..."
|
|
100
|
-
});
|
|
132
|
+
System-only endpoint. The server's arbiter key signs the on-chain release. Requires the `X-Release-Secret` header to be set — this should only be called by your backend/system trigger after confirming both parties have marked ready.
|
|
101
133
|
|
|
102
|
-
|
|
103
|
-
await sdk.escrow.release(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
134
|
+
```typescript
|
|
135
|
+
const { data } = await sdk.escrow.release(
|
|
136
|
+
"43113", // chainId
|
|
137
|
+
"0xEscrowAddress...",
|
|
138
|
+
{ recipient: "0xSellerAddress..." } // optional, defaults to seller
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// data: { success, txHash, escrowAddress, arbiter }
|
|
107
142
|
```
|
|
143
|
+
|
|
144
|
+
> **Note:** Call `getStatus` first to confirm `readyForRelease` and `buyerReleaseReady` are both `true` before triggering release.
|
package/dist/main.d.ts
CHANGED
|
@@ -51,10 +51,8 @@ declare const parseUrlWithQuery: (url: string, filter: object | any) => string;
|
|
|
51
51
|
interface EscrowModuleType {
|
|
52
52
|
create(data: CreateEscrowDto): Promise<ResponseDto<CreateEscrowResponse>>;
|
|
53
53
|
getStatus(chainId: string, escrowAddress: string): Promise<ResponseDto<EscrowStatusResponse>>;
|
|
54
|
-
release(escrowAddress: string, data?: ReleaseDto): Promise<ResponseDto<ReleaseResponse>>;
|
|
55
|
-
updateStatus(
|
|
56
|
-
prepareRelease(escrowAddress: string, recipient?: string): Promise<ResponseDto<PrepareTransactionResponse>>;
|
|
57
|
-
list(params?: ListEscrowsParams): Promise<ResponseDto<ListEscrowsResponse>>;
|
|
54
|
+
release(chainId: string, escrowAddress: string, data?: ReleaseDto): Promise<ResponseDto<ReleaseResponse>>;
|
|
55
|
+
updateStatus(data: UpdateEscrowStatusDto): Promise<ResponseDto<PrepareTransactionResponse>>;
|
|
58
56
|
getChains(): Promise<ResponseDto<GetEscrowChainsResponseDto>>;
|
|
59
57
|
getAssets(chainId: string): Promise<ResponseDto<GetEscrowAssetsResponseDto>>;
|
|
60
58
|
}
|
|
@@ -95,19 +93,6 @@ interface CreateEscrowResponse {
|
|
|
95
93
|
};
|
|
96
94
|
};
|
|
97
95
|
}
|
|
98
|
-
interface ComputeAddressParams {
|
|
99
|
-
sender: string;
|
|
100
|
-
receiver: string;
|
|
101
|
-
asset: string;
|
|
102
|
-
amount: string;
|
|
103
|
-
originator: string;
|
|
104
|
-
salt: string;
|
|
105
|
-
metadataHash?: string;
|
|
106
|
-
}
|
|
107
|
-
interface ComputeAddressResponse {
|
|
108
|
-
predictedAddress: string;
|
|
109
|
-
exists: boolean;
|
|
110
|
-
}
|
|
111
96
|
interface EscrowStatusResponse {
|
|
112
97
|
chainId: string;
|
|
113
98
|
escrow: string;
|
|
@@ -168,29 +153,6 @@ interface PrepareTransactionResponse {
|
|
|
168
153
|
buyer?: string;
|
|
169
154
|
nonce?: string;
|
|
170
155
|
}
|
|
171
|
-
interface ListEscrowsParams {
|
|
172
|
-
sender?: string;
|
|
173
|
-
receiver?: string;
|
|
174
|
-
status?: "pending" | "deposited" | "released";
|
|
175
|
-
page?: number;
|
|
176
|
-
limit?: number;
|
|
177
|
-
}
|
|
178
|
-
interface EscrowListItem {
|
|
179
|
-
address: string;
|
|
180
|
-
sender: string;
|
|
181
|
-
receiver: string;
|
|
182
|
-
asset: string;
|
|
183
|
-
amount: string;
|
|
184
|
-
deposited: boolean;
|
|
185
|
-
released: boolean;
|
|
186
|
-
createdAt: string;
|
|
187
|
-
}
|
|
188
|
-
interface ListEscrowsResponse {
|
|
189
|
-
total: number;
|
|
190
|
-
page: number;
|
|
191
|
-
limit: number;
|
|
192
|
-
escrows: EscrowListItem[];
|
|
193
|
-
}
|
|
194
156
|
interface EscrowNativeCurrencyDto {
|
|
195
157
|
name: string;
|
|
196
158
|
symbol: string;
|
|
@@ -223,21 +185,14 @@ declare class EscrowService implements EscrowModuleType {
|
|
|
223
185
|
constructor(id: string);
|
|
224
186
|
create(data: CreateEscrowDto): Promise<ResponseDto<CreateEscrowResponse>>;
|
|
225
187
|
getStatus(chainId: string, escrowAddress: string): Promise<ResponseDto<EscrowStatusResponse>>;
|
|
226
|
-
updateStatus(
|
|
227
|
-
|
|
228
|
-
address: string;
|
|
229
|
-
}): Promise<ResponseDto<PrepareTransactionResponse>>;
|
|
230
|
-
prepareRelease(escrowAddress: string, recipient?: string): Promise<ResponseDto<PrepareTransactionResponse>>;
|
|
231
|
-
release(escrowAddress: string, data?: {
|
|
232
|
-
recipient?: string;
|
|
233
|
-
}): Promise<ResponseDto<ReleaseResponse>>;
|
|
234
|
-
list(params?: ListEscrowsParams): Promise<ResponseDto<ListEscrowsResponse>>;
|
|
188
|
+
updateStatus(data: UpdateEscrowStatusDto): Promise<ResponseDto<PrepareTransactionResponse>>;
|
|
189
|
+
release(chainId: string, escrowAddress: string, data?: ReleaseDto): Promise<ResponseDto<ReleaseResponse>>;
|
|
235
190
|
getChains(): Promise<ResponseDto<GetEscrowChainsResponseDto>>;
|
|
236
191
|
getAssets(chainId: string): Promise<ResponseDto<GetEscrowAssetsResponseDto>>;
|
|
237
192
|
}
|
|
238
193
|
|
|
239
194
|
interface PsiloSDKConfig {
|
|
240
|
-
baseUrl
|
|
195
|
+
baseUrl?: string;
|
|
241
196
|
verbose?: boolean;
|
|
242
197
|
}
|
|
243
198
|
declare class PsiloSDK {
|
|
@@ -255,4 +210,4 @@ declare class SDKError extends Error {
|
|
|
255
210
|
constructor(message: string, code?: string, details?: any);
|
|
256
211
|
}
|
|
257
212
|
|
|
258
|
-
export {
|
|
213
|
+
export { Connector, CreateEscrowDto, CreateEscrowResponse, DepositDto, DepositResponse, ErrorUtils, EscrowAssetDto, EscrowChainDto, EscrowModuleType, EscrowNativeCurrencyDto, EscrowService, EscrowStatusResponse, GetEscrowAssetsResponseDto, GetEscrowChainsResponseDto, IAny, PrepareTransactionResponse, PsiloSDK, PsiloSDKConfig, ReleaseDto, ReleaseResponse, ResponseDto, SDKError, SignReleaseDto, SignReleaseResponse, StandardResponse, Status, UpdateEscrowStatusDto, parseUrlWithQuery };
|
package/dist/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Q=Object.create;var d=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames,v=Object.getOwnPropertySymbols,_=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var E=(r,t,e)=>t in r?d(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,h=(r,t)=>{for(var e in t||(t={}))C.call(t,e)&&E(r,e,t[e]);if(v)for(var e of v(t))G.call(t,e)&&E(r,e,t[e]);return r};var o=(r,t)=>d(r,"name",{value:t,configurable:!0});var V=(r,t)=>{for(var e in t)d(r,e,{get:t[e],enumerable:!0})},z=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of K(t))!C.call(r,s)&&s!==e&&d(r,s,{get:()=>t[s],enumerable:!(n=B(t,s))||n.enumerable});return r};var X=(r,t,e)=>(e=r!=null?Q(_(r)):{},z(t||!r||!r.__esModule?d(e,"default",{value:r,enumerable:!0}):e,r)),Y=r=>z(d({},"__esModule",{value:!0}),r);var i=(r,t,e)=>(E(r,typeof t!="symbol"?t+"":t,e),e);var st={};V(st,{Connector:()=>l,ErrorUtils:()=>p,EscrowService:()=>m,PsiloSDK:()=>R,SDKError:()=>u,Status:()=>et,parseUrlWithQuery:()=>N});module.exports=Y(st);var oe=require("reflect-metadata");var g=require("typedi");var D=X(require("axios"));var j=class j extends Error{constructor(e,n,s){super(e);i(this,"code");i(this,"details");this.name="SDKError",this.code=n,this.details=s}};o(j,"SDKError");var u=j;var F=class F{constructor(t){i(this,"client");this.client=D.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}setHeader(t,e){this.client.defaults.headers.common[t]=e}removeHeader(t){delete this.client.defaults.headers.common[t]}handleResponse(t){var n,s,a;let e=t.data;if(e&&e.success===!1)throw new u(((n=e.error)==null?void 0:n.message)||"Unknown error",((s=e.error)==null?void 0:s.code)||"API_ERROR",(a=e.error)==null?void 0:a.details);return e}handleError(t){var e,n;if(D.default.isAxiosError(t)){let s=(e=t.response)==null?void 0:e.data;throw s&&s.error?new u(s.error.message||t.message,s.error.code||"REQUEST_ERROR",s.error.details):new u(t.message,t.code,(n=t.response)==null?void 0:n.data)}throw new u(t.message||"An unexpected error occurred","INTERNAL_ERROR")}async get(t,e){try{let n=await this.client.get(t,e);return this.handleResponse(n)}catch(n){this.handleError(n)}}async post(t,e,n){try{let s=await this.client.post(t,e,n);return this.handleResponse(s)}catch(s){this.handleError(s)}}async put(t,e,n){try{let s=await this.client.put(t,e,n);return this.handleResponse(s)}catch(s){this.handleError(s)}}async delete(t,e){try{let n=await this.client.delete(t,e);return this.handleResponse(n)}catch(n){this.handleError(n)}}};o(F,"Connector");var l=F;var b=require("typedi");var Z={delayFirstAttempt:!1,jitter:"none",maxDelay:1/0,numOfAttempts:10,retry:()=>!0,startingDelay:100,timeMultiple:2};function J(r){let t=h(h({},Z),r);return t.numOfAttempts<1&&(t.numOfAttempts=1),t}o(J,"getSanitizedOptions");function P(r){let t=Math.random()*r;return Math.round(t)}o(P,"fullJitter");function W(r){return r}o(W,"noJitter");function $(r){switch(r.jitter){case"full":return P;case"none":default:return W}}o($,"JitterFactory");var S=class S{constructor(t){i(this,"options");i(this,"attempt",0);this.options=t}apply(){return new Promise(t=>setTimeout(t,this.jitteredDelay))}setAttemptNumber(t){this.attempt=t}get jitteredDelay(){return $(this.options)(this.delay)}get delay(){let t=this.options.startingDelay,e=this.options.timeMultiple,n=this.numOfDelayedAttempts,s=t*Math.pow(e,n);return Math.min(s,this.options.maxDelay)}get numOfDelayedAttempts(){return this.attempt}};o(S,"Delay");var y=S;var M=class M extends y{async apply(){return this.isFirstAttempt?!0:super.apply()}get isFirstAttempt(){return this.attempt===0}get numOfDelayedAttempts(){return this.attempt-1}};o(M,"SkipFirstDelay");var O=M;var U=class U extends y{};o(U,"AlwaysDelay");var A=U;function q(r,t){let e=k(r);return e.setAttemptNumber(t),e}o(q,"DelayFactory");function k(r){return r.delayFirstAttempt?new A(r):new O(r)}o(k,"initDelayClass");async function I(r,t={}){let e=J(t);return await new tt(r,e).execute()}o(I,"backOff");var w,tt=(w=class{constructor(t,e){i(this,"request");i(this,"options");i(this,"attemptNumber",0);this.request=t,this.options=e}async execute(){for(;!this.attemptLimitReached;)try{return await this.applyDelay(),await this.request()}catch(t){if(this.attemptNumber++,!await this.options.retry(t,this.attemptNumber)||this.attemptLimitReached)throw t}throw new Error("Something went wrong.")}get attemptLimitReached(){return this.attemptNumber>=this.options.numOfAttempts}async applyDelay(){await q(this.options,this.attemptNumber).apply()}},o(w,"BackOff"),w);var et=function(r){return r.SUCCESS="success",r.ERROR="error",r}({}),p={newTryFail:async r=>{try{let t=await I(async()=>await r(),{startingDelay:50,timeMultiple:10,numOfAttempts:10,maxDelay:3550,delayFirstAttempt:!1});return h({},t)}catch(t){let e=p.toErrorWithMessage(t);return{data:null,status:"error",message:e?e.message:["Internal Server Error"],code:e.code}}},formatErrorMsg:r=>r.replace("attr.",""),toErrorWithMessage:r=>{var t;if(typeof r=="string")try{let e=JSON.parse(r);return e.data instanceof Array&&e.data.length>0?{message:e.data.map(n=>p.formatErrorMsg(n)),code:e.errorCode}:{message:[(t=e.message)!=null?t:r],code:e.errorCode}}catch(e){}if(p.isErrorWithMessage(r))return{message:[r.message]};try{return{message:[JSON.stringify(r,null,2)]}}catch(e){return{message:[String(r)]}}},isErrorWithMessage(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}},N=o((r,t)=>{let e="?",n=Object.keys(t||{});return n.length===0?r:(n.map((s,a)=>{let c="&";(s===void 0||s==="undefined"||s===null||s==="null"||s.length===0)&&(e=e),a+1===n.length&&(c=""),e=e+`${s}=${t[s]}${c}`}),r+e)},"parseUrlWithQuery");function rt(r,t,e,n){var s=arguments.length,a=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,n);else for(var f=r.length-1;f>=0;f--)(c=r[f])&&(a=(s<3?c(a):s>3?c(t,e,a):c(t,e))||a);return s>3&&a&&Object.defineProperty(t,e,a),a}o(rt,"_ts_decorate");function H(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}o(H,"_ts_metadata");var T=class T{constructor(t){i(this,"id");i(this,"connector");this.id=t,this.connector=b.Container.of(this.id).get(l)}async create(t){return p.newTryFail(async()=>await this.connector.post("/api/escrow/create",t))}async getStatus(t,e){return p.newTryFail(async()=>{let n=N("/api/escrow/status",{chainId:t,escrow:e});return await this.connector.get(n)})}async updateStatus(t){return p.newTryFail(async()=>await this.connector.post("/api/escrow/update",t))}async release(t,e,n){return p.newTryFail(async()=>{let s=h({chainId:t,escrowAddress:e},n||{});return await this.connector.post("/api/escrow/release",s)})}async getChains(){return p.newTryFail(async()=>await this.connector.get("/api/escrow/chains"))}async getAssets(t){return p.newTryFail(async()=>await this.connector.get(`/api/escrow/assets/${t}`))}};o(T,"EscrowService");var m=T;m=rt([(0,b.Service)({factory:r=>new m(r.id),transient:!0}),H("design:type",Function),H("design:paramtypes",[String])],m);function nt(r,t,e,n){var s=arguments.length,a=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,n);else for(var f=r.length-1;f>=0;f--)(c=r[f])&&(a=(s<3?c(a):s>3?c(t,e,a):c(t,e))||a);return s>3&&a&&Object.defineProperty(t,e,a),a}o(nt,"_ts_decorate");function L(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}o(L,"_ts_metadata");var x=class x{constructor(t){i(this,"escrow");i(this,"connector");this.connector=g.Container.of(t).get(l),this.escrow=g.Container.of(t).get(m)}static async init(t){if(!t.baseUrl)throw new Error("PsiloSDK initialization requires a valid baseUrl");t.verbose&&console.log(`[PsiloSDK] Initializing SDK pointed to ${t.baseUrl}`);let e=x.generateRandomString(),n=new l(t.baseUrl);return g.Container.of(e).set(l,n),new x(e)}setAuthorizationHeader(t){this.connector.setHeader("Authorization",`Bearer ${t}`)}static generateRandomString(){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let n=0;n<60;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}};o(x,"PsiloSDK");var R=x;R=nt([(0,g.Service)({transient:!0}),L("design:type",Function),L("design:paramtypes",[String])],R);0&&(module.exports={Connector,ErrorUtils,EscrowService,PsiloSDK,SDKError,Status,parseUrlWithQuery});
|
|
2
2
|
//# sourceMappingURL=main.js.map
|