@swapkit/core 5.1.0 → 5.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @swapkit/core
2
2
 
3
+ ## 5.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#426](https://github.com/swapkit/sdk/pull/426) [`489fa6c`](https://github.com/swapkit/sdk/commit/489fa6c90f668c65b3b7ec2a7d355449f5312ce2) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Add Relay support: `ProviderName.RELAY` is now available, and Relay routes resolve to the generic `swapkit` plugin for any wallet (like Flashnet, Mayan and PactSwap), which signs the route's prebuilt EVM transaction.
8
+ - [#427](https://github.com/swapkit/sdk/pull/427) [`607fac7`](https://github.com/swapkit/sdk/commit/607fac77adfa5fc2e3bd221c71a82b2a99337b56) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - `getTHORNameCost` and `getMAYANameCost` now match on-chain pricing: the 10 RUNE / 10 CACAO registration fee already includes the first year, and each extra year costs 1.0512 (20 tor or 2000 base units per block × 5,256,000 blocks). (via @swapkit/helpers@6.1.0)
9
+ - [#415](https://github.com/swapkit/sdk/pull/415) [`3e3dca0`](https://github.com/swapkit/sdk/commit/3e3dca0aea7625917a797c1a8183c60a47ae5574) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update generated token lists. (via @swapkit/helpers@6.1.0)
10
+ - [#372](https://github.com/swapkit/sdk/pull/372) [`3f07d19`](https://github.com/swapkit/sdk/commit/3f07d19c90e320d1f04ce4088efa66f2edcff24d) Thanks [@ice-chillios](https://github.com/ice-chillios)! - **New `estimateTronSweepDeduction({ assetValue, recipient, memo?, timeoutMs? })`** — a bounded, recipient-aware quote-time reserve for a Tron sweep. A caller reserving a flat constant cannot see a fresh recipient's activation cost, so an address funded with exactly the sell amount swept short of activating the destination and the transfer failed on chain. (via @swapkit/toolboxes@6.1.0)
11
+ - [#422](https://github.com/swapkit/sdk/pull/422) [`8a1e977`](https://github.com/swapkit/sdk/commit/8a1e977fc99eae87beb62390066d835a721b5c37) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Use an external UTXO signer's optional account `publicKey` consistently in `transfer`, `createTransaction` and `createReplacementTransaction`, so nested segwit and taproot inputs receive their spending metadata. The key must be a 33-byte `Uint8Array`; other values throw `toolbox_utxo_invalid_params`. (via @swapkit/toolboxes@6.1.0)
12
+
13
+ ## 5.1.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [#424](https://github.com/swapkit/sdk/pull/424) [`3254bf4`](https://github.com/swapkit/sdk/commit/3254bf4d7496289307c2f22edabf627f63479611) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Solana: the payer SOL check for SPL transfers that create the recipient's associated token account is now opt-in. Pass `checkPayerBalance: true` to `createTransaction` or `transfer` to get `toolbox_solana_insufficient_balance` instead of a transaction that fails simulation; by default no extra RPC calls are made and the transaction is returned as before. The recipient token account is still created with `CreateIdempotent`. (via @swapkit/toolboxes@6.0.1)
18
+ - [#415](https://github.com/swapkit/sdk/pull/415) [`3e3dca0`](https://github.com/swapkit/sdk/commit/3e3dca0aea7625917a797c1a8183c60a47ae5574) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update generated token lists. (via @swapkit/toolboxes@6.0.1)
19
+
3
20
  ## 5.1.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var R=((i)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(c,w)=>(typeof require<"u"?require:c)[w]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});import{ApproveMode as m,AssetValue as g,Chain as f,CosmosChains as z,EVMChains as k,ProviderName as _,SKConfig as J,SwapKitError as l,UTXOChains as Z}from"@swapkit/helpers";import{parseTransactionValue as ee}from"@swapkit/helpers/api";export*from"@swapkit/helpers";var te=[_.FLASHNET,_.MAYAN,_.PACTSWAP];function ne({pluginName:i,providers:c,useDirectSigning:w}){return c.some((T)=>te.includes(T))||w?"swapkit":i||c[0]}function ae(i){let c="approvalTx"in i?i.approvalTx:void 0;return c!==void 0&&"txType"in c&&c.txType==="STELLAR"?g.from({asset:i.buyAsset}):g.from({asset:i.sellAsset,value:i.sellAmount})}function ie({config:i,plugins:c,wallets:w}={}){if(i)J.set(i);let y={},T=Object.entries(c||{}).reduce((e,[n,t])=>{let a=t({getWallet:o});return e[n]=a,e},{}),W=Object.entries(w||{}).reduce((e,[n,t])=>{let a=t.connectWallet({addChain:E});return e[n]=a,e},{});function b(e){let n=e&&T[e],t=Object.values(T).find((s)=>s.supportedSwapkitProviders?.includes(e)),a=n||t;if(!a)throw new l("core_plugin_not_found");return a}function E(e){let n=o(e.chain),t=e?.balance||n?.balance||[g.from({chain:e.chain})],a={...n,...e,balance:t};return y[e.chain]=a,a}function C({pluginName:e,route:n,useDirectSigning:t}){return b(ne({pluginName:e,providers:n.providers,useDirectSigning:t}))}function M({assetValue:e,plugin:n,route:t,spenderAddress:a,type:s}){if(s===m.CheckOnly&&"isAssetValueApproved"in n)return n.isAssetValueApproved({assetValue:e,route:t,spenderAddress:a});if(s===m.Approve&&"approveAssetValue"in n)return n.approveAssetValue({assetValue:e,route:t,spenderAddress:a});throw new l({errorKey:"core_approve_asset_target_invalid",info:{message:`Target ${String(a??t?.providers[0])} cannot be used for approve operation`}})}function P({assetValue:e,type:n="checkOnly",contractAddress:t,route:a}){let s=e??(a?ae(a):void 0);if(!s)throw new l("core_approve_asset_target_invalid");let r=t??a?.meta.approvalAddress,h=a?C({route:a,useDirectSigning:Boolean(o(s.chain)?.supportsDirectSigning)}):r&&T[r];if(h)return M({assetValue:s,plugin:h,route:a,spenderAddress:r,type:n});let V=s.chain,u=k.includes(V);if(u&&s.isGasAsset||!u||s.isSynthetic)return Promise.resolve(n==="checkOnly"?!0:"approved");let p=o(V),A=n==="checkOnly"?p.isApproved:p.approve;if(!A)throw new l("core_wallet_connection_not_found");if(!(s.address&&p.address&&typeof r==="string"))throw new l("core_approve_asset_address_or_from_not_found");return A({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:p.address,spenderAddress:r})}function o(e){return y[e]}function O(){return{...y}}function F(e){return o(e)?.address||""}function K(e,n){return e instanceof g?P({assetValue:e,contractAddress:n,type:m.Approve}):P({route:e,type:m.Approve})}function D(e,n){return e instanceof g?P({assetValue:e,contractAddress:n,type:m.CheckOnly}):P({route:e,type:m.CheckOnly})}function S(e){o(e)?.disconnect?.(),delete y[e]}function B(){for(let e of Object.keys(y))S(e)}function I(e,n){return n?x(e).then(({balance:t})=>t):o(e)?.balance||[]}async function x(e,n=!0){let t=o(e);if(!t)throw new l("core_wallet_connection_not_found");let a=await t.getBalance?.(t.address,n);return t.balance=a||[g.from({chain:e})],t}function G({route:e,pluginName:n,...t}){let a=g.from({asset:e.sellAsset}).chain,s=o(a);if(!s)throw new l("core_wallet_connection_not_found");let r=C({pluginName:n,route:e,useDirectSigning:Boolean(s.supportsDirectSigning&&e.tx)});if("swap"in r)return r.swap({...t,route:e});throw new l("core_plugin_swap_not_found")}function L({assetValue:e,...n}){let t=e.chain;if([f.Radix].includes(t)||!o(t))throw new l("core_wallet_connection_not_found");return o(t).transfer({...n,assetValue:e})}function j({chain:e,message:n}){let t=o(e);if(!t)throw new l("core_wallet_connection_not_found");if("signMessage"in t)return t.signMessage?.(n);throw new l({errorKey:"core_wallet_sign_message_not_supported",info:{chain:e,wallet:t.walletType}})}function H({chain:e,domain:n,primaryType:t,types:a,value:s}){let r=o(e);if(!r)throw new l("core_wallet_connection_not_found");if("signTypedData"in r&&typeof r.signTypedData==="function")return r.signTypedData({domain:n,primaryType:t,types:a,value:s});throw new l({errorKey:"core_wallet_sign_typed_data_not_supported",info:{chain:e,wallet:r.walletType}})}async function Q({address:e,chain:n,message:t,signature:a}){if(n!==f.THORChain)throw new l({errorKey:"core_verify_message_not_supported",info:{chain:n}});let{getCosmosToolbox:s}=await import("@swapkit/toolboxes/cosmos");return s(n).verifySignature({address:e,message:t,signature:a})}async function U({type:e,feeOptionKey:n,params:t}){let{assetValue:a}=t,{chain:s}=a;if(!o(s))throw new l("core_wallet_connection_not_found");let r=g.from({chain:s}),{match:h}=await import("ts-pattern");return await h(s).returnType().with(...k,(u)=>{let{address:d,...p}=o(u),A=h(e).with("transfer",()=>p.createTransferTx(t)).with("approve",(Y)=>{let{contractAddress:v}=t;return p.createApprovalTx({amount:a.getBaseValue("bigint"),assetAddress:a.address,from:d,spenderAddress:v})}).with("swap",(Y)=>{let{route:{providers:[v],tx:q}}=t;if(v&&[_.CHAINFLIP,_.CHAINFLIP_STREAMING].includes(v))return p.createTransferTx({assetValue:a,recipient:d,sender:d});let N=q;return{...N,value:ee(N.value)}}).otherwise(()=>{return});if(!A)return r;return p.estimateTransactionFee({...A,feeOption:n})}).with(...z,async()=>{let{estimateTransactionFee:u}=await import("@swapkit/toolboxes/cosmos");return u(t)}).with(...Z,(u)=>{let{address:d,...p}=o(u);return p.estimateTransactionFee({...t,feeOptionKey:n,recipient:d,sender:d})}).with(f.Tron,f.Ton,f.Polkadot,(u)=>{let{address:d,...p}=o(u);return p.estimateTransactionFee({...t,recipient:d,sender:d})}).with(f.Aptos,f.Cardano,f.Ripple,f.Stellar,f.Sui,(u)=>o(u).estimateTransactionFee()).otherwise(()=>r)}async function X({address:e,chain:n}){try{let{getAddressValidator:t}=await import("@swapkit/toolboxes");return(await t())({address:e,chain:n})}catch{return!1}}return{...T,...W,approveAssetValue:K,disconnectAll:B,disconnectChain:S,estimateTransactionFee:U,getAddress:F,getAllWallets:O,getBalance:I,getWallet:o,getWalletWithBalance:x,isAssetValueApproved:D,signMessage:j,signTypedData:H,swap:G,transfer:L,validateAddress:X,verifyMessage:Q}}export{ie as SwapKit,ae as getRouteApprovalAssetValue,ne as resolveRoutePluginName};
1
+ var R=((i)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(c,w)=>(typeof require<"u"?require:c)[w]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});import{ApproveMode as m,AssetValue as g,Chain as f,CosmosChains as z,EVMChains as k,ProviderName as h,SKConfig as J,SwapKitError as l,UTXOChains as Z}from"@swapkit/helpers";import{parseTransactionValue as ee}from"@swapkit/helpers/api";export*from"@swapkit/helpers";var te=[h.FLASHNET,h.MAYAN,h.PACTSWAP,h.RELAY];function ne({pluginName:i,providers:c,useDirectSigning:w}){return c.some((T)=>te.includes(T))||w?"swapkit":i||c[0]}function ae(i){let c="approvalTx"in i?i.approvalTx:void 0;return c!==void 0&&"txType"in c&&c.txType==="STELLAR"?g.from({asset:i.buyAsset}):g.from({asset:i.sellAsset,value:i.sellAmount})}function ie({config:i,plugins:c,wallets:w}={}){if(i)J.set(i);let y={},T=Object.entries(c||{}).reduce((e,[n,t])=>{let a=t({getWallet:o});return e[n]=a,e},{}),W=Object.entries(w||{}).reduce((e,[n,t])=>{let a=t.connectWallet({addChain:E});return e[n]=a,e},{});function b(e){let n=e&&T[e],t=Object.values(T).find((s)=>s.supportedSwapkitProviders?.includes(e)),a=n||t;if(!a)throw new l("core_plugin_not_found");return a}function E(e){let n=o(e.chain),t=e?.balance||n?.balance||[g.from({chain:e.chain})],a={...n,...e,balance:t};return y[e.chain]=a,a}function C({pluginName:e,route:n,useDirectSigning:t}){return b(ne({pluginName:e,providers:n.providers,useDirectSigning:t}))}function M({assetValue:e,plugin:n,route:t,spenderAddress:a,type:s}){if(s===m.CheckOnly&&"isAssetValueApproved"in n)return n.isAssetValueApproved({assetValue:e,route:t,spenderAddress:a});if(s===m.Approve&&"approveAssetValue"in n)return n.approveAssetValue({assetValue:e,route:t,spenderAddress:a});throw new l({errorKey:"core_approve_asset_target_invalid",info:{message:`Target ${String(a??t?.providers[0])} cannot be used for approve operation`}})}function P({assetValue:e,type:n="checkOnly",contractAddress:t,route:a}){let s=e??(a?ae(a):void 0);if(!s)throw new l("core_approve_asset_target_invalid");let r=t??a?.meta.approvalAddress,A=a?C({route:a,useDirectSigning:Boolean(o(s.chain)?.supportsDirectSigning)}):r&&T[r];if(A)return M({assetValue:s,plugin:A,route:a,spenderAddress:r,type:n});let V=s.chain,u=k.includes(V);if(u&&s.isGasAsset||!u||s.isSynthetic)return Promise.resolve(n==="checkOnly"?!0:"approved");let p=o(V),_=n==="checkOnly"?p.isApproved:p.approve;if(!_)throw new l("core_wallet_connection_not_found");if(!(s.address&&p.address&&typeof r==="string"))throw new l("core_approve_asset_address_or_from_not_found");return _({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:p.address,spenderAddress:r})}function o(e){return y[e]}function O(){return{...y}}function F(e){return o(e)?.address||""}function K(e,n){return e instanceof g?P({assetValue:e,contractAddress:n,type:m.Approve}):P({route:e,type:m.Approve})}function D(e,n){return e instanceof g?P({assetValue:e,contractAddress:n,type:m.CheckOnly}):P({route:e,type:m.CheckOnly})}function S(e){o(e)?.disconnect?.(),delete y[e]}function B(){for(let e of Object.keys(y))S(e)}function I(e,n){return n?x(e).then(({balance:t})=>t):o(e)?.balance||[]}async function x(e,n=!0){let t=o(e);if(!t)throw new l("core_wallet_connection_not_found");let a=await t.getBalance?.(t.address,n);return t.balance=a||[g.from({chain:e})],t}function L({route:e,pluginName:n,...t}){let a=g.from({asset:e.sellAsset}).chain,s=o(a);if(!s)throw new l("core_wallet_connection_not_found");let r=C({pluginName:n,route:e,useDirectSigning:Boolean(s.supportsDirectSigning&&e.tx)});if("swap"in r)return r.swap({...t,route:e});throw new l("core_plugin_swap_not_found")}function G({assetValue:e,...n}){let t=e.chain;if([f.Radix].includes(t)||!o(t))throw new l("core_wallet_connection_not_found");return o(t).transfer({...n,assetValue:e})}function j({chain:e,message:n}){let t=o(e);if(!t)throw new l("core_wallet_connection_not_found");if("signMessage"in t)return t.signMessage?.(n);throw new l({errorKey:"core_wallet_sign_message_not_supported",info:{chain:e,wallet:t.walletType}})}function H({chain:e,domain:n,primaryType:t,types:a,value:s}){let r=o(e);if(!r)throw new l("core_wallet_connection_not_found");if("signTypedData"in r&&typeof r.signTypedData==="function")return r.signTypedData({domain:n,primaryType:t,types:a,value:s});throw new l({errorKey:"core_wallet_sign_typed_data_not_supported",info:{chain:e,wallet:r.walletType}})}async function Q({address:e,chain:n,message:t,signature:a}){if(n!==f.THORChain)throw new l({errorKey:"core_verify_message_not_supported",info:{chain:n}});let{getCosmosToolbox:s}=await import("@swapkit/toolboxes/cosmos");return s(n).verifySignature({address:e,message:t,signature:a})}async function U({type:e,feeOptionKey:n,params:t}){let{assetValue:a}=t,{chain:s}=a;if(!o(s))throw new l("core_wallet_connection_not_found");let r=g.from({chain:s}),{match:A}=await import("ts-pattern");return await A(s).returnType().with(...k,(u)=>{let{address:d,...p}=o(u),_=A(e).with("transfer",()=>p.createTransferTx(t)).with("approve",(X)=>{let{contractAddress:v}=t;return p.createApprovalTx({amount:a.getBaseValue("bigint"),assetAddress:a.address,from:d,spenderAddress:v})}).with("swap",(X)=>{let{route:{providers:[v],tx:q}}=t;if(v&&[h.CHAINFLIP,h.CHAINFLIP_STREAMING].includes(v))return p.createTransferTx({assetValue:a,recipient:d,sender:d});let N=q;return{...N,value:ee(N.value)}}).otherwise(()=>{return});if(!_)return r;return p.estimateTransactionFee({..._,feeOption:n})}).with(...z,async()=>{let{estimateTransactionFee:u}=await import("@swapkit/toolboxes/cosmos");return u(t)}).with(...Z,(u)=>{let{address:d,...p}=o(u);return p.estimateTransactionFee({...t,feeOptionKey:n,recipient:d,sender:d})}).with(f.Tron,f.Ton,f.Polkadot,(u)=>{let{address:d,...p}=o(u);return p.estimateTransactionFee({...t,recipient:d,sender:d})}).with(f.Aptos,f.Cardano,f.Ripple,f.Stellar,f.Sui,(u)=>o(u).estimateTransactionFee()).otherwise(()=>r)}async function Y({address:e,chain:n}){try{let{getAddressValidator:t}=await import("@swapkit/toolboxes");return(await t())({address:e,chain:n})}catch{return!1}}return{...T,...W,approveAssetValue:K,disconnectAll:B,disconnectChain:S,estimateTransactionFee:U,getAddress:F,getAllWallets:O,getBalance:I,getWallet:o,getWalletWithBalance:x,isAssetValueApproved:D,signMessage:j,signTypedData:H,swap:L,transfer:G,validateAddress:Y,verifyMessage:Q}}export{ie as SwapKit,ae as getRouteApprovalAssetValue,ne as resolveRoutePluginName};
@@ -4917,7 +4917,7 @@ export declare function SwapKit<Plugins extends ReturnType<typeof createPlugin>,
4917
4917
  SOL: ChainWallet<Chain.Solana> & {
4918
4918
  broadcastTransaction: (transaction: import("@solana/web3.js/lib").Transaction | import("@solana/web3.js/lib").VersionedTransaction) => Promise<string>;
4919
4919
  createKeysForPath: typeof import("@swapkit/toolboxes/solana/toolbox").createKeysForPath;
4920
- createTransaction: ({ recipient, assetValue, memo, isProgramDerivedAddress, sender, recentBlockhash, sweep, }: import("@swapkit/toolboxes/solana/index").SolanaCreateTransactionParams) => Promise<import("@solana/web3.js/lib").Transaction>;
4920
+ createTransaction: ({ checkPayerBalance, recipient, assetValue, memo, isProgramDerivedAddress, sender, recentBlockhash, sweep, }: import("@swapkit/toolboxes/solana/index").SolanaCreateTransactionParams) => Promise<import("@solana/web3.js/lib").Transaction>;
4921
4921
  createTransactionFromInstructions: ({ instructions, }: {
4922
4922
  instructions: import("@solana/web3.js/lib").TransactionInstruction[];
4923
4923
  isProgramDerivedAddress?: boolean;
@@ -4933,7 +4933,7 @@ export declare function SwapKit<Plugins extends ReturnType<typeof createPlugin>,
4933
4933
  getPubkeyFromAddress: (address: string) => import("@solana/web3.js/lib").PublicKey;
4934
4934
  signAndBroadcastTransaction: (transaction: import("@solana/web3.js/lib").Transaction | import("@solana/web3.js/lib").VersionedTransaction) => Promise<string>;
4935
4935
  signTransaction: (transaction: import("@solana/web3.js/lib").Transaction | import("@solana/web3.js/lib").VersionedTransaction) => Promise<import("@solana/web3.js/lib").Transaction | import("@solana/web3.js/lib").VersionedTransaction>;
4936
- transfer: ({ recipient, assetValue, memo, isProgramDerivedAddress, sweep }: import("@swapkit/toolboxes/solana/index").SolanaTransferParams) => Promise<string>;
4936
+ transfer: ({ recipient, assetValue, checkPayerBalance, memo, isProgramDerivedAddress, sweep, }: import("@swapkit/toolboxes/solana/index").SolanaTransferParams) => Promise<string>;
4937
4937
  validateAddress: typeof import("@swapkit/toolboxes/solana/toolbox").validateSolanaAddress;
4938
4938
  };
4939
4939
  SONIC: ChainWallet<Chain.Sonic> & {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "author": "swapkit-dev",
3
3
  "dependencies": {
4
- "@swapkit/helpers": "6.0.0",
5
- "@swapkit/plugins": "5.0.10",
6
- "@swapkit/toolboxes": "6.0.0",
7
- "@swapkit/wallet-core": "5.0.10"
4
+ "@swapkit/helpers": "6.1.0",
5
+ "@swapkit/plugins": "5.0.12",
6
+ "@swapkit/toolboxes": "6.1.0",
7
+ "@swapkit/wallet-core": "5.0.12"
8
8
  },
9
9
  "description": "SwapKit - Core",
10
10
  "devDependencies": {
@@ -34,5 +34,5 @@
34
34
  "type-check:go": "tsgo"
35
35
  },
36
36
  "type": "module",
37
- "version": "5.1.0"
37
+ "version": "5.2.0"
38
38
  }