@shogun-sdk/swap 0.0.2-test.23 → 0.0.2-test.24

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.
@@ -38,10 +38,11 @@ var adaptSolanaWallet = (walletAddress, chainId, rpcUrl, signAndSendTransaction)
38
38
  };
39
39
 
40
40
  // src/wallet-adapter/evm-wallet-adapter/adapter.ts
41
- import "ethers/lib/ethers.js";
41
+ import { utils as ethersUtils } from "ethers/lib/ethers.js";
42
42
  import { hexValue } from "ethers/lib/utils.js";
43
43
  import {
44
- custom
44
+ custom,
45
+ publicActions
45
46
  } from "viem";
46
47
  function isEVMTransaction(tx) {
47
48
  return typeof tx.from === "string";
@@ -78,6 +79,21 @@ var adaptEthersSigner = (signer, transport) => {
78
79
  throw error;
79
80
  }
80
81
  };
82
+ const readContract = async ({
83
+ address,
84
+ abi,
85
+ functionName,
86
+ args = []
87
+ }) => {
88
+ const iface = new ethersUtils.Interface(abi);
89
+ const fnArgs = Array.isArray(args) ? args : [];
90
+ const data = iface.encodeFunctionData(functionName, fnArgs);
91
+ const provider = signer.provider;
92
+ if (!provider) throw new Error("Signer has no provider");
93
+ const result = await provider.call({ to: address, data });
94
+ const decoded = iface.decodeFunctionResult(functionName, result);
95
+ return decoded[0];
96
+ };
81
97
  return {
82
98
  vmType: "EVM" /* EVM */,
83
99
  transport,
@@ -85,7 +101,8 @@ var adaptEthersSigner = (signer, transport) => {
85
101
  address: async () => signer.getAddress(),
86
102
  sendTransaction,
87
103
  signTypedData,
88
- switchChain
104
+ switchChain,
105
+ readContract
89
106
  };
90
107
  };
91
108
  var adaptViemWallet = (wallet) => {
@@ -144,6 +161,20 @@ var adaptViemWallet = (wallet) => {
144
161
  if (!addr) throw new Error("No address found");
145
162
  return addr;
146
163
  };
164
+ const readContract = async ({
165
+ address: address2,
166
+ abi,
167
+ functionName,
168
+ args = []
169
+ }) => {
170
+ const publicClient = wallet.extend(publicActions);
171
+ return await publicClient.readContract({
172
+ address: address2,
173
+ abi,
174
+ functionName,
175
+ args
176
+ });
177
+ };
147
178
  return {
148
179
  vmType: "EVM" /* EVM */,
149
180
  transport: custom(wallet.transport),
@@ -151,7 +182,8 @@ var adaptViemWallet = (wallet) => {
151
182
  address,
152
183
  sendTransaction,
153
184
  signTypedData,
154
- switchChain
185
+ switchChain,
186
+ readContract
155
187
  };
156
188
  };
157
189
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shogun-sdk/swap",
3
- "version": "0.0.2-test.23",
3
+ "version": "0.0.2-test.24",
4
4
  "type": "module",
5
5
  "description": "Shogun Network Swap utilities and helpers",
6
6
  "author": "Shogun Network",
@@ -57,7 +57,7 @@
57
57
  "@solana/web3.js": "^1.98.4",
58
58
  "ethers": "^5.6.1",
59
59
  "wagmi": "2.18.0",
60
- "@shogun-sdk/intents-sdk": "1.2.6-test.6"
60
+ "@shogun-sdk/intents-sdk": "1.2.6-test.8"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "viem": "^2.38.1",