@cowprotocol/sdk-viem-adapter 0.3.18 → 0.3.20
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 +1 -35
- package/dist/index.js +3 -1
- package/dist/index.mjs +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,41 +37,7 @@ const provider = createPublicClient({ chain: sepolia, transport })
|
|
|
37
37
|
const adapter = new ViemAdapter({ provider, signer: account })
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
###
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { CowSdk, SupportedChainId } from '@cowprotocol/cow-sdk'
|
|
44
|
-
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
45
|
-
import { http, createPublicClient, privateKeyToAccount } from 'viem'
|
|
46
|
-
import { sepolia } from 'viem/chains'
|
|
47
|
-
|
|
48
|
-
// Configure the adapter
|
|
49
|
-
const account = privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
50
|
-
const transport = http('YOUR_RPC_URL')
|
|
51
|
-
const provider = createPublicClient({ chain: sepolia, transport })
|
|
52
|
-
// You also can set `walletClient` instead of `signer` using `useWalletClient` from wagmi
|
|
53
|
-
const adapter = new ViemAdapter({ provider, signer: account })
|
|
54
|
-
|
|
55
|
-
// Initialize the unified SDK
|
|
56
|
-
const sdk = new CowSdk({
|
|
57
|
-
chainId: SupportedChainId.SEPOLIA,
|
|
58
|
-
adapter,
|
|
59
|
-
tradingOptions: {
|
|
60
|
-
traderParams: {
|
|
61
|
-
appCode: 'YOUR_APP_CODE',
|
|
62
|
-
},
|
|
63
|
-
options: {
|
|
64
|
-
chainId: SupportedChainId.SEPOLIA,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
// Use the SDK
|
|
70
|
-
const orderId = await sdk.trading.postSwapOrder(parameters)
|
|
71
|
-
const orders = await sdk.orderBook.getOrders({ owner: address })
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Using with Individual Packages
|
|
40
|
+
### Example
|
|
75
41
|
|
|
76
42
|
```typescript
|
|
77
43
|
import { TradingSdk } from '@cowprotocol/sdk-trading'
|
package/dist/index.js
CHANGED
|
@@ -635,11 +635,13 @@ var ViemSignerAdapter = class extends import_sdk_common3.AbstractSigner {
|
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
637
|
const formattedTx = this._formatTxParams(txParams);
|
|
638
|
+
const rawValue = formattedTx.value;
|
|
639
|
+
const value = rawValue === void 0 || rawValue === null ? "0x0" : typeof rawValue === "string" && rawValue.startsWith("0x") ? rawValue : "0x" + BigInt(rawValue).toString(16);
|
|
638
640
|
const params = {
|
|
639
641
|
from: typeof this._account === "string" ? this._account : this._account.address,
|
|
640
642
|
to: formattedTx.to,
|
|
641
643
|
data: formattedTx.data,
|
|
642
|
-
value
|
|
644
|
+
value
|
|
643
645
|
};
|
|
644
646
|
const hexGas = await this._publicClient.request({
|
|
645
647
|
method: "eth_estimateGas",
|
package/dist/index.mjs
CHANGED
|
@@ -661,11 +661,13 @@ var ViemSignerAdapter = class extends AbstractSigner {
|
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
663
|
const formattedTx = this._formatTxParams(txParams);
|
|
664
|
+
const rawValue = formattedTx.value;
|
|
665
|
+
const value = rawValue === void 0 || rawValue === null ? "0x0" : typeof rawValue === "string" && rawValue.startsWith("0x") ? rawValue : "0x" + BigInt(rawValue).toString(16);
|
|
664
666
|
const params = {
|
|
665
667
|
from: typeof this._account === "string" ? this._account : this._account.address,
|
|
666
668
|
to: formattedTx.to,
|
|
667
669
|
data: formattedTx.data,
|
|
668
|
-
value
|
|
670
|
+
value
|
|
669
671
|
};
|
|
670
672
|
const hexGas = await this._publicClient.request({
|
|
671
673
|
method: "eth_estimateGas",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/sdk-viem-adapter",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.20",
|
|
4
4
|
"description": "Viem adapter for CoW Protocol SDK",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@cowprotocol/sdk-common": "0.10.
|
|
21
|
+
"@cowprotocol/sdk-common": "0.10.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"viem": "^2.28.4"
|