Skip to content

Commit 6dc0659

Browse files
committed
Update to web3js version >1.92
1 parent 7e23e4b commit 6dc0659

File tree

4 files changed

+946
-915
lines changed

4 files changed

+946
-915
lines changed

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
"version": "0.4.1",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
6-
"files": [
7-
"dist/"
8-
],
6+
"files": ["dist/"],
97
"license": "MIT",
108
"devDependencies": {
119
"@coral-xyz/anchor": "^0.30.0",
12-
"@solana/web3.js": ">=1.78.4 <1.92.0",
10+
"@solana/web3.js": ">1.92.0",
1311
"@types/bn.js": "^5.1.1",
1412
"@types/bs58": "^4.0.1",
1513
"@types/jest": "^29.5.3",
@@ -37,7 +35,7 @@
3735
"packageManager": "[email protected]",
3836
"peerDependencies": {
3937
"@coral-xyz/anchor": "^0.30.0",
40-
"@solana/web3.js": ">=1.78.4 <1.92.0",
38+
"@solana/web3.js": ">1.92.0",
4139
"solana-bankrun": "^0.2.0"
4240
}
4341
}

src/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,19 @@ async function sendWithErr(
7373
if (errMsg !== null) {
7474
if (maybeMeta !== null) {
7575
const logs = maybeMeta.logMessages;
76-
const formattedLogs = `Logs: \n${JSON.stringify(logs, null, 2)}`;
77-
throw new Error(`${errMsg}\n${formattedLogs}`);
76+
throw new SendTransactionError({
77+
action: "send",
78+
signature: "",
79+
transactionMessage: errMsg,
80+
logs: logs,
81+
});
7882
} else {
79-
throw new Error(errMsg);
83+
throw new SendTransactionError({
84+
action: "send",
85+
signature: "",
86+
transactionMessage: errMsg,
87+
logs: [],
88+
});
8089
}
8190
}
8291
}

tests/main.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@ test("error test", async () => {
5454

5555
const data = new BN(123456);
5656
const expectedMsg =
57-
"AnchorError caused by account: puppet. Error Code: AccountNotInitialized. \
58-
Error Number: 3012. Error Message: \
59-
The program expected this account to be already initialized.";
57+
"AnchorError caused by account: puppet. Error Code: AccountNotInitialized.";
6058
const expectedLogs = [
6159
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS invoke [1]",
6260
"Program log: Instruction: SetData",
6361
"Program log: AnchorError caused by account: puppet. Error Code: AccountNotInitialized. Error Number: 3012. Error Message: The program expected this account to be already initialized.",
6462
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS consumed 3621 of 200000 compute units",
6563
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS failed: custom program error: 0xbc4",
6664
];
65+
6766
const wrap = async () => {
6867
await puppetProgram.methods
6968
.setData(data)
@@ -72,7 +71,12 @@ The program expected this account to be already initialized.";
7271
})
7372
.rpc();
7473
};
75-
await expect(wrap).rejects.toThrow(new SendTransactionError(expectedMsg));
74+
await expect(wrap).rejects.toThrow(
75+
expect.objectContaining({
76+
message: expect.stringContaining(expectedMsg),
77+
}),
78+
);
79+
7680
await expect(wrap).rejects.toHaveProperty("logs", expectedLogs);
7781
});
7882

0 commit comments

Comments
 (0)