Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
v0.1.6-a2
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseTheRobot committed Feb 2, 2024
1 parent 8648f40 commit 317fa77
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@irys/sdk",
"version": "0.1.6-a1",
"version": "0.1.6-a2",
"description": "JS client for Irys",
"repository": "https://github.com/Bundlr-Network/js-client.git",
"author": "Irys",
Expand Down Expand Up @@ -119,7 +119,7 @@
"aptos": "=1.8.5",
"arbundles": "^0.10.0",
"async-retry": "^1.3.3",
"axios": "^1.4.0",
"axios": "^1.6.7",
"base64url": "^3.0.1",
"bignumber.js": "^9.0.1",
"bs58": "5.0.0",
Expand Down
27 changes: 19 additions & 8 deletions src/web/shims/viemv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import type { mainnet } from "viem/chains";
import type { Tx } from "src/common/types";
import type EthereumConfig from "../tokens/ethereum";
import type ERC20Config from "../tokens/erc20";
import { InjectedTypedEthereumSigner } from "arbundles/web";

// TODO: figure out a better way to do this.
export async function augmentViemV2(tokenConfig: EthereumConfig, opts: any): Promise<void> {
export function augmentViemV2(tokenConfig: EthereumConfig, opts: any): void {
const walletClient = opts.provider as WalletClient;
const publicClient = opts.publicClient as PublicClient<ReturnType<typeof http>, typeof mainnet>;

Expand All @@ -19,13 +20,23 @@ export async function augmentViemV2(tokenConfig: EthereumConfig, opts: any): Pro
}.bind(tokenConfig);

tokenConfig.getFee = async (_amount) => new BigNumber(0);
opts.provider.getSigner = () => ({
getAddress: async () => walletClient.getAddresses().then((r) => r[0]),
_signTypedData: async (domain, types, message): Promise<string> => {
message["Transaction hash"] = "0x" + Buffer.from(message["Transaction hash"]).toString("hex");
return await walletClient.signTypedData({ account: message.address, domain, types, primaryType: "Bundlr", message });
},
});

tokenConfig.getSigner = function () {
if (!this.signer) {
this.signer = new InjectedTypedEthereumSigner({
getSigner: () => ({
getAddress: async () => walletClient.getAddresses().then((r) => r[0]),
_signTypedData: async (domain, types, message): Promise<string> => {
message["Transaction hash"] = "0x" + Buffer.from(message["Transaction hash"]).toString("hex");
// @ts-expect-error types
return await walletClient.signTypedData({ account: message.address, domain, types, primaryType: "Bundlr", message });
},
}),
});
}
return this.signer;
}.bind(tokenConfig);

tokenConfig.getCurrentHeight = async () => new BigNumber((await publicClient.getBlockNumber()).toString());

// if this is ERC20
Expand Down

0 comments on commit 317fa77

Please sign in to comment.