@swapkit/core 4.4.41 → 4.4.42
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 +20 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +1678 -110
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @swapkit/core
|
|
2
2
|
|
|
3
|
+
## 4.4.42
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Accept base-10 and hex integer EVM-compatible transaction values, expose shared value parsing helpers, and add TRON/TON quote tx types.
|
|
8
|
+
|
|
9
|
+
Emit hex `value` fields from EVM transaction creators.
|
|
10
|
+
|
|
11
|
+
Expose hex `value` fields from Tron toolbox-created transactions.
|
|
12
|
+
|
|
13
|
+
Update TON transaction payloads to use `{ sendMode, messages }`, while keeping TON toolbox signing compatible with legacy message-array inputs.
|
|
14
|
+
|
|
15
|
+
Keep SwapKit plugin signing compatible with legacy TON message-array inputs through August 26, 2026.
|
|
16
|
+
|
|
17
|
+
- Updated dependencies:
|
|
18
|
+
- @swapkit/helpers@4.15.3
|
|
19
|
+
- @swapkit/toolboxes@4.20.1
|
|
20
|
+
- @swapkit/plugins@4.6.56
|
|
21
|
+
- @swapkit/wallet-core@4.3.10
|
|
22
|
+
|
|
3
23
|
## 4.4.41
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var{defineProperty:B,getOwnPropertyNames:K,getOwnPropertyDescriptor:
|
|
1
|
+
var{defineProperty:B,getOwnPropertyNames:K,getOwnPropertyDescriptor:t}=Object,M=Object.prototype.hasOwnProperty;function b(J){return this[J]}var k=(J,L,I)=>{var U=K(L);for(let $ of U)if(!M.call(J,$)&&$!=="default")B(J,$,{get:b.bind(L,$),enumerable:!0});if(I){for(let $ of U)if(!M.call(I,$)&&$!=="default")B(I,$,{get:b.bind(L,$),enumerable:!0});return I}};var l=(J)=>{var L=(C??=new WeakMap).get(J),I;if(L)return L;if(L=B({},"__esModule",{value:!0}),J&&typeof J==="object"||typeof J==="function"){for(var U of K(J))if(!M.call(L,U))B(L,U,{get:b.bind(J,U),enumerable:!(I=t(J,U))||I.enumerable})}return C.set(J,L),L},C;var a=(J)=>J;function e(J,L){this[J]=a.bind(null,L)}var jj=(J,L)=>{for(var I in L)B(J,I,{get:L[I],enumerable:!0,configurable:!0,set:e.bind(L,I)})};var F={};jj(F,{SwapKit:()=>zj});module.exports=l(F);var q=require("@swapkit/helpers"),y=require("@swapkit/helpers/api");k(F,require("@swapkit/helpers"),module.exports);var qj=[q.ProviderName.FLASHNET,q.ProviderName.MAYAN];function zj({config:J,plugins:L,wallets:I}={}){if(J)q.SKConfig.set(J);let U={},$=Object.entries(L||{}).reduce((j,[G,z])=>{let H=z({getWallet:Q});return j[G]=H,j},{}),E=Object.entries(I||{}).reduce((j,[G,z])=>{let H=z.connectWallet({addChain:A});return j[G]=H,j},{});function T(j){let G=j&&$[j],z=Object.values($).find((Z)=>Z.supportedSwapkitProviders?.includes(j)),H=G||z;if(!H)throw new q.SwapKitError("core_plugin_not_found");return H}function A(j){let G=Q(j.chain),z=j?.balance||G?.balance||[q.AssetValue.from({chain:j.chain})],H={...G,...j,balance:z};return U[j.chain]=H,H}function P({assetValue:j,type:G="checkOnly",contractAddress:z}){let H=$[z];if(H){if(G===q.ApproveMode.CheckOnly&&"isAssetValueApproved"in H)return H.isAssetValueApproved({assetValue:j});if(G===q.ApproveMode.Approve&&"approveAssetValue"in H)return H.approveAssetValue({assetValue:j});throw new q.SwapKitError({errorKey:"core_approve_asset_target_invalid",info:{message:`Target ${String(z)} cannot be used for approve operation`}})}let Z=j.chain,X=q.EVMChains.includes(Z);if(X&&j.isGasAsset||!X||j.isSynthetic)return Promise.resolve(G==="checkOnly"?!0:"approved");let R=Q(Z),Y=G==="checkOnly"?R.isApproved:R.approve;if(!Y)throw new q.SwapKitError("core_wallet_connection_not_found");if(!(j.address&&R.address&&typeof z==="string"))throw new q.SwapKitError("core_approve_asset_address_or_from_not_found");return Y({amount:j.getBaseValue("bigint"),assetAddress:j.address,from:R.address,spenderAddress:z})}function Q(j){return U[j]}function V(){return{...U}}function W(j){return Q(j)?.address||""}function m(j,G){return P({assetValue:j,contractAddress:G,type:q.ApproveMode.Approve})}function w(j,G){return P({assetValue:j,contractAddress:G,type:q.ApproveMode.CheckOnly})}function f(j){Q(j)?.disconnect?.(),delete U[j]}function h(){for(let j of Object.keys(U))f(j)}function g(j,G){return G?N(j).then(({balance:z})=>z):Q(j)?.balance||[]}async function N(j,G=!0){let z=Q(j);if(!z)throw new q.SwapKitError("core_wallet_connection_not_found");let H=await z.getBalance?.(z.address,G);return z.balance=H||[q.AssetValue.from({chain:j})],z}function d({route:j,pluginName:G,...z}){let H=q.AssetValue.from({asset:j.sellAsset}).chain,Z=Q(H);if(!Z)throw new q.SwapKitError("core_wallet_connection_not_found");let X=j.providers.some((Y)=>qj.includes(Y));if(Z.supportsDirectSigning&&j.tx||X){let Y=T("swapkit");if("swap"in Y)return Y.swap({...z,route:j})}let R=T(G||j.providers[0]);if("swap"in R)return R.swap({...z,route:j});throw new q.SwapKitError("core_plugin_swap_not_found")}function u({assetValue:j,...G}){let z=j.chain;if([q.Chain.Radix].includes(z)||!Q(z))throw new q.SwapKitError("core_wallet_connection_not_found");return Q(z).transfer({...G,assetValue:j})}function o({chain:j,message:G}){let z=Q(j);if(!z)throw new q.SwapKitError("core_wallet_connection_not_found");if("signMessage"in z)return z.signMessage?.(G);throw new q.SwapKitError({errorKey:"core_wallet_sign_message_not_supported",info:{chain:j,wallet:z.walletType}})}function p({chain:j,domain:G,primaryType:z,types:H,value:Z}){let X=Q(j);if(!X)throw new q.SwapKitError("core_wallet_connection_not_found");if("signTypedData"in X&&typeof X.signTypedData==="function")return X.signTypedData({domain:G,primaryType:z,types:H,value:Z});throw new q.SwapKitError({errorKey:"core_wallet_sign_typed_data_not_supported",info:{chain:j,wallet:X.walletType}})}async function c({address:j,chain:G,message:z,signature:H}){if(G!==q.Chain.THORChain)throw new q.SwapKitError({errorKey:"core_verify_message_not_supported",info:{chain:G}});let{getCosmosToolbox:Z}=await import("@swapkit/toolboxes/cosmos");return Z(G).verifySignature({address:j,message:z,signature:H})}async function r({type:j,feeOptionKey:G,params:z}){let{assetValue:H}=z,{chain:Z}=H;if(!Q(Z))throw new q.SwapKitError("core_wallet_connection_not_found");let X=q.AssetValue.from({chain:Z}),{match:O}=await import("ts-pattern");return await O(Z).returnType().with(...q.EVMChains,(Y)=>{let{address:_,...D}=Q(Y),S=O(j).with("transfer",()=>D.createTransferTx(z)).with("approve",(n)=>{let{contractAddress:x}=z;return D.createApprovalTx({amount:H.getBaseValue("bigint"),assetAddress:H.address,from:_,spenderAddress:x})}).with("swap",(n)=>{let{route:{providers:[x],tx:s}}=z;if(x&&[q.ProviderName.CHAINFLIP,q.ProviderName.CHAINFLIP_STREAMING].includes(x))return D.createTransferTx({assetValue:H,recipient:_,sender:_});let v=s;return{...v,value:y.parseTransactionValue(v.value)}}).otherwise(()=>{return});if(!S)return X;return D.estimateTransactionFee({...S,feeOption:G})}).with(...q.CosmosChains,async()=>{let{estimateTransactionFee:Y}=await import("@swapkit/toolboxes/cosmos");return Y(z)}).with(...q.UTXOChains,(Y)=>{let{address:_,...D}=Q(Y);return D.estimateTransactionFee({...z,feeOptionKey:G,recipient:_,sender:_})}).with(q.Chain.Tron,q.Chain.Ton,q.Chain.Polkadot,(Y)=>{let{address:_,...D}=Q(Y);return D.estimateTransactionFee({...z,recipient:_,sender:_})}).with(q.Chain.Aptos,q.Chain.Cardano,q.Chain.Ripple,q.Chain.Stellar,q.Chain.Sui,(Y)=>Q(Y).estimateTransactionFee()).otherwise(()=>X)}async function i({address:j,chain:G}){try{let{getAddressValidator:z}=await import("@swapkit/toolboxes");return(await z())({address:j,chain:G})}catch{return!1}}return{...$,...E,approveAssetValue:m,disconnectAll:h,disconnectChain:f,estimateTransactionFee:r,getAddress:W,getAllWallets:V,getBalance:g,getWallet:Q,getWalletWithBalance:N,isAssetValueApproved:w,signMessage:o,signTypedData:p,swap:d,transfer:u,validateAddress:i,verifyMessage:c}}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var k=((U)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(U,{get:(M,
|
|
1
|
+
var k=((U)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(U,{get:(M,b)=>(typeof require<"u"?require:M)[b]}):U)(function(U){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+U+'" is not supported')});import{ApproveMode as B,AssetValue as O,Chain as Z,CosmosChains as n,EVMChains as C,ProviderName as x,SKConfig as s,SwapKitError as Y,UTXOChains as t}from"@swapkit/helpers";import{parseTransactionValue as l}from"@swapkit/helpers/api";export*from"@swapkit/helpers";var a=[x.FLASHNET,x.MAYAN];function zj({config:U,plugins:M,wallets:b}={}){if(U)s.set(U);let _={},R=Object.entries(M||{}).reduce((j,[z,q])=>{let G=q({getWallet:H});return j[z]=G,j},{}),K=Object.entries(b||{}).reduce((j,[z,q])=>{let G=q.connectWallet({addChain:y});return j[z]=G,j},{});function T(j){let z=j&&R[j],q=Object.values(R).find((L)=>L.supportedSwapkitProviders?.includes(j)),G=z||q;if(!G)throw new Y("core_plugin_not_found");return G}function y(j){let z=H(j.chain),q=j?.balance||z?.balance||[O.from({chain:j.chain})],G={...z,...j,balance:q};return _[j.chain]=G,G}function P({assetValue:j,type:z="checkOnly",contractAddress:q}){let G=R[q];if(G){if(z===B.CheckOnly&&"isAssetValueApproved"in G)return G.isAssetValueApproved({assetValue:j});if(z===B.Approve&&"approveAssetValue"in G)return G.approveAssetValue({assetValue:j});throw new Y({errorKey:"core_approve_asset_target_invalid",info:{message:`Target ${String(q)} cannot be used for approve operation`}})}let L=j.chain,Q=C.includes(L);if(Q&&j.isGasAsset||!Q||j.isSynthetic)return Promise.resolve(z==="checkOnly"?!0:"approved");let X=H(L),J=z==="checkOnly"?X.isApproved:X.approve;if(!J)throw new Y("core_wallet_connection_not_found");if(!(j.address&&X.address&&typeof q==="string"))throw new Y("core_approve_asset_address_or_from_not_found");return J({amount:j.getBaseValue("bigint"),assetAddress:j.address,from:X.address,spenderAddress:q})}function H(j){return _[j]}function E(){return{..._}}function A(j){return H(j)?.address||""}function V(j,z){return P({assetValue:j,contractAddress:z,type:B.Approve})}function W(j,z){return P({assetValue:j,contractAddress:z,type:B.CheckOnly})}function f(j){H(j)?.disconnect?.(),delete _[j]}function m(){for(let j of Object.keys(_))f(j)}function w(j,z){return z?N(j).then(({balance:q})=>q):H(j)?.balance||[]}async function N(j,z=!0){let q=H(j);if(!q)throw new Y("core_wallet_connection_not_found");let G=await q.getBalance?.(q.address,z);return q.balance=G||[O.from({chain:j})],q}function h({route:j,pluginName:z,...q}){let G=O.from({asset:j.sellAsset}).chain,L=H(G);if(!L)throw new Y("core_wallet_connection_not_found");let Q=j.providers.some((J)=>a.includes(J));if(L.supportsDirectSigning&&j.tx||Q){let J=T("swapkit");if("swap"in J)return J.swap({...q,route:j})}let X=T(z||j.providers[0]);if("swap"in X)return X.swap({...q,route:j});throw new Y("core_plugin_swap_not_found")}function g({assetValue:j,...z}){let q=j.chain;if([Z.Radix].includes(q)||!H(q))throw new Y("core_wallet_connection_not_found");return H(q).transfer({...z,assetValue:j})}function d({chain:j,message:z}){let q=H(j);if(!q)throw new Y("core_wallet_connection_not_found");if("signMessage"in q)return q.signMessage?.(z);throw new Y({errorKey:"core_wallet_sign_message_not_supported",info:{chain:j,wallet:q.walletType}})}function u({chain:j,domain:z,primaryType:q,types:G,value:L}){let Q=H(j);if(!Q)throw new Y("core_wallet_connection_not_found");if("signTypedData"in Q&&typeof Q.signTypedData==="function")return Q.signTypedData({domain:z,primaryType:q,types:G,value:L});throw new Y({errorKey:"core_wallet_sign_typed_data_not_supported",info:{chain:j,wallet:Q.walletType}})}async function o({address:j,chain:z,message:q,signature:G}){if(z!==Z.THORChain)throw new Y({errorKey:"core_verify_message_not_supported",info:{chain:z}});let{getCosmosToolbox:L}=await import("@swapkit/toolboxes/cosmos");return L(z).verifySignature({address:j,message:q,signature:G})}async function p({type:j,feeOptionKey:z,params:q}){let{assetValue:G}=q,{chain:L}=G;if(!H(L))throw new Y("core_wallet_connection_not_found");let Q=O.from({chain:L}),{match:D}=await import("ts-pattern");return await D(L).returnType().with(...C,(J)=>{let{address:$,...I}=H(J),S=D(j).with("transfer",()=>I.createTransferTx(q)).with("approve",(r)=>{let{contractAddress:F}=q;return I.createApprovalTx({amount:G.getBaseValue("bigint"),assetAddress:G.address,from:$,spenderAddress:F})}).with("swap",(r)=>{let{route:{providers:[F],tx:i}}=q;if(F&&[x.CHAINFLIP,x.CHAINFLIP_STREAMING].includes(F))return I.createTransferTx({assetValue:G,recipient:$,sender:$});let v=i;return{...v,value:l(v.value)}}).otherwise(()=>{return});if(!S)return Q;return I.estimateTransactionFee({...S,feeOption:z})}).with(...n,async()=>{let{estimateTransactionFee:J}=await import("@swapkit/toolboxes/cosmos");return J(q)}).with(...t,(J)=>{let{address:$,...I}=H(J);return I.estimateTransactionFee({...q,feeOptionKey:z,recipient:$,sender:$})}).with(Z.Tron,Z.Ton,Z.Polkadot,(J)=>{let{address:$,...I}=H(J);return I.estimateTransactionFee({...q,recipient:$,sender:$})}).with(Z.Aptos,Z.Cardano,Z.Ripple,Z.Stellar,Z.Sui,(J)=>H(J).estimateTransactionFee()).otherwise(()=>Q)}async function c({address:j,chain:z}){try{let{getAddressValidator:q}=await import("@swapkit/toolboxes");return(await q())({address:j,chain:z})}catch{return!1}}return{...R,...K,approveAssetValue:V,disconnectAll:m,disconnectChain:f,estimateTransactionFee:p,getAddress:A,getAllWallets:E,getBalance:w,getWallet:H,getWalletWithBalance:N,isAssetValueApproved:W,signMessage:d,signTypedData:u,swap:h,transfer:g,validateAddress:c,verifyMessage:o}}export{zj as SwapKit};
|