@gardenfi/core 2.5.2 → 2.5.3

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 CHANGED
@@ -1,19 +1,17 @@
1
1
  # @gardenfi/core
2
2
 
3
- The `@gardenfi/core` package serves as an abstraction layer over the `@catalogfi/wallets`(contains different kind of bitcoin and evm wallets) and `@gardenfi/orderbook` packages. It provides a simple interface to perform atomic swaps.
3
+ The `@gardenfi/core` package handles atomic swaps between different blockchains. It provides an interface for applications to integrate the Garden SDK. The Garden instance provides all required functionalities such as quote generation, swap initiation, HTLC interactions, and wallet operations.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```
8
- npm install `@gardenfi/core`
8
+ yarn add `@gardenfi/core`
9
9
  ```
10
10
 
11
- For more information regarding using the library in different environments see [setup](https://github.com/catalogfi/garden.js/tree/main/packages/core#setup).
12
-
13
11
  ## Usage
14
12
 
15
- 1. Creating an atomic swap: ([should create an order with valid parameters](https://github.com/catalogfi/garden.js/blob/4623a0679d1948755500c7179113112a025e33f8/packages/core/src/lib/garden.spec.ts#L91))
16
- 2. Interacting with created orders: ([should initiate and redeem](https://github.com/catalogfi/garden.js/blob/4623a0679d1948755500c7179113112a025e33f8/packages/core/src/lib/garden.spec.ts#L107))
13
+ 1. Creating an atomic swap: ([should create an order with valid parameters](https://github.com/hashiraio/garden.js/blob/main/packages/core/src/lib/garden/garden.spec.ts#L150))
14
+ 2. Interacting with created orders: ([should initiate and redeem](https://github.com/hashiraio/garden.js/blob/main/packages/core/src/lib/garden/garden.spec.ts#L197))
17
15
 
18
16
  ## Setup
19
17
 
@@ -36,10 +34,10 @@ npm install vite-plugin-wasm vite-plugin-top-level-await vite-plugin-node-polyfi
36
34
  and update your `vite.config.ts` as follows:
37
35
 
38
36
  ```typescript
39
- import { defineConfig } from "vite";
40
- import wasm from "vite-plugin-wasm";
41
- import { nodePolyfills } from "vite-plugin-node-polyfills";
42
- import topLevelAwait from "vite-plugin-top-level-await";
37
+ import { defineConfig } from 'vite';
38
+ import wasm from 'vite-plugin-wasm';
39
+ import { nodePolyfills } from 'vite-plugin-node-polyfills';
40
+ import topLevelAwait from 'vite-plugin-top-level-await';
43
41
 
44
42
  export default defineConfig({
45
43
  plugins: [
@@ -1,4 +1,4 @@
1
- import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-BsWv07Gh.js";
1
+ import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-D-NHDZrP.js";
2
2
  class S extends p {
3
3
  constructor({ callbackSelector: r, cause: a, data: n, extraData: i, sender: f, urls: t }) {
4
4
  var o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-9VBMeQEM.cjs");class w extends e.BaseError{constructor({callbackSelector:o,cause:a,data:c,extraData:u,sender:d,urls:r}){var n;super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],(n=a.metaMessages)!=null&&n.length?"":[],"Offchain Gateway Call:",r&&[" Gateway URL(s):",...r.map(f=>` ${e.getUrl(f)}`)],` Sender: ${d}`,` Data: ${c}`,` Callback selector: ${o}`,` Extra data: ${u}`].flat(),name:"OffchainLookupError"})}}class k extends e.BaseError{constructor({result:o,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${e.getUrl(a)}`,`Response: ${e.stringify(o)}`],name:"OffchainLookupResponseMalformedError"})}}class b extends e.BaseError{constructor({sender:o,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${o}`],name:"OffchainLookupSenderMismatchError"})}}const L="0x556f1830",y={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function E(i,{blockNumber:o,blockTag:a,data:c,to:u}){const{args:d}=e.decodeErrorResult({data:c,abi:[y]}),[r,n,f,l,s]=d,{ccipRead:t}=i,h=t&&typeof(t==null?void 0:t.request)=="function"?t.request:m;try{if(!e.isAddressEqual(u,r))throw new b({sender:r,to:u});const p=n.includes(e.localBatchGatewayUrl)?await e.localBatchGatewayRequest({data:f,ccipRequest:h}):await h({data:f,sender:r,urls:n}),{data:g}=await e.call(i,{blockNumber:o,blockTag:a,data:e.concat([l,e.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[p,s])]),to:u});return g}catch(p){throw new w({callbackSelector:l,cause:p,data:c,extraData:s,sender:r,urls:n})}}async function m({data:i,sender:o,urls:a}){var u;let c=new Error("An unknown error occurred.");for(let d=0;d<a.length;d++){const r=a[d],n=r.includes("{data}")?"GET":"POST",f=n==="POST"?{data:i,sender:o}:void 0,l=n==="POST"?{"Content-Type":"application/json"}:{};try{const s=await fetch(r.replace("{sender}",o.toLowerCase()).replace("{data}",i),{body:JSON.stringify(f),headers:l,method:n});let t;if((u=s.headers.get("Content-Type"))!=null&&u.startsWith("application/json")?t=(await s.json()).data:t=await s.text(),!s.ok){c=new e.HttpRequestError({body:f,details:t!=null&&t.error?e.stringify(t.error):s.statusText,headers:s.headers,status:s.status,url:r});continue}if(!e.isHex(t)){c=new k({result:t,url:r});continue}return t}catch(s){c=new e.HttpRequestError({body:f,details:s.message,url:r})}}throw c}exports.ccipRequest=m;exports.offchainLookup=E;exports.offchainLookupAbiItem=y;exports.offchainLookupSignature=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-s2tkcnpk.cjs");class w extends e.BaseError{constructor({callbackSelector:o,cause:a,data:c,extraData:u,sender:d,urls:r}){var n;super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],(n=a.metaMessages)!=null&&n.length?"":[],"Offchain Gateway Call:",r&&[" Gateway URL(s):",...r.map(f=>` ${e.getUrl(f)}`)],` Sender: ${d}`,` Data: ${c}`,` Callback selector: ${o}`,` Extra data: ${u}`].flat(),name:"OffchainLookupError"})}}class k extends e.BaseError{constructor({result:o,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${e.getUrl(a)}`,`Response: ${e.stringify(o)}`],name:"OffchainLookupResponseMalformedError"})}}class b extends e.BaseError{constructor({sender:o,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${o}`],name:"OffchainLookupSenderMismatchError"})}}const L="0x556f1830",y={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function E(i,{blockNumber:o,blockTag:a,data:c,to:u}){const{args:d}=e.decodeErrorResult({data:c,abi:[y]}),[r,n,f,l,s]=d,{ccipRead:t}=i,h=t&&typeof(t==null?void 0:t.request)=="function"?t.request:m;try{if(!e.isAddressEqual(u,r))throw new b({sender:r,to:u});const p=n.includes(e.localBatchGatewayUrl)?await e.localBatchGatewayRequest({data:f,ccipRequest:h}):await h({data:f,sender:r,urls:n}),{data:g}=await e.call(i,{blockNumber:o,blockTag:a,data:e.concat([l,e.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[p,s])]),to:u});return g}catch(p){throw new w({callbackSelector:l,cause:p,data:c,extraData:s,sender:r,urls:n})}}async function m({data:i,sender:o,urls:a}){var u;let c=new Error("An unknown error occurred.");for(let d=0;d<a.length;d++){const r=a[d],n=r.includes("{data}")?"GET":"POST",f=n==="POST"?{data:i,sender:o}:void 0,l=n==="POST"?{"Content-Type":"application/json"}:{};try{const s=await fetch(r.replace("{sender}",o.toLowerCase()).replace("{data}",i),{body:JSON.stringify(f),headers:l,method:n});let t;if((u=s.headers.get("Content-Type"))!=null&&u.startsWith("application/json")?t=(await s.json()).data:t=await s.text(),!s.ok){c=new e.HttpRequestError({body:f,details:t!=null&&t.error?e.stringify(t.error):s.statusText,headers:s.headers,status:s.status,url:r});continue}if(!e.isHex(t)){c=new k({result:t,url:r});continue}return t}catch(s){c=new e.HttpRequestError({body:f,details:s.message,url:r})}}throw c}exports.ccipRequest=m;exports.offchainLookup=E;exports.offchainLookupAbiItem=y;exports.offchainLookupSignature=L;