Skip to content

Commit 4f9ec6d

Browse files
committed
fix @project-serum/anchor publickey issue
to remove after solana-foundation/anchor#1138 is merged
1 parent 7c3a9bc commit 4f9ec6d

File tree

4 files changed

+172
-83
lines changed

4 files changed

+172
-83
lines changed

next.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ const withTM = require('next-transpile-modules')(['react-markdown'])
55
module.exports = withTM({
66
target: 'serverless',
77
webpack: (config, { isServer }) => {
8+
config.resolve = {
9+
...config.resolve,
10+
alias: {
11+
...config.resolve.alias,
12+
'@project-serum/anchor$': '@project-serum/anchor/dist/esm',
13+
},
14+
}
815
config.module.rules.push({
916
test: /\.svg$/,
1017
use: ['@svgr/webpack'],

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"lint": "eslint . --ext ts --ext tsx --ext js --ext jsx",
1515
"test": "jest",
1616
"test-all": "yarn lint && yarn type-check && yarn test",
17-
"notifier": "TS_NODE_PROJECT=./tsconfig.commonjs.json ts-node scripts/governance-notifier.ts"
17+
"notifier": "TS_NODE_PROJECT=./tsconfig.commonjs.json ts-node scripts/governance-notifier.ts",
18+
"postinstall": "patch-package"
1819
},
1920
"lint-staged": {
2021
"*.@(ts|tsx|js|jsx)": [
@@ -23,16 +24,16 @@
2324
},
2425
"dependencies": {
2526
"@blockworks-foundation/mango-client": "^3.2.15",
26-
"@project-serum/anchor": "^0.19.0",
27-
"@solana/spl-token": "^0.1.8",
28-
"@solana/web3.js": "1.31.0",
2927
"@emotion/react": "^11.1.5",
3028
"@emotion/styled": "^11.3.0",
3129
"@headlessui/react": "^1.0.0",
3230
"@heroicons/react": "^1.0.1",
31+
"@project-serum/anchor": "^0.19.0",
3332
"@project-serum/borsh": "^0.2.2",
3433
"@project-serum/common": "^0.0.1-beta.3",
3534
"@project-serum/sol-wallet-adapter": "^0.2.0",
35+
"@solana/spl-token": "^0.1.8",
36+
"@solana/web3.js": "1.31.0",
3637
"@tippyjs/react": "^4.2.5",
3738
"@uxdprotocol/uxd-client": "^2.56.0",
3839
"axios": "^0.21.1",
@@ -71,8 +72,10 @@
7172
"jest": "^26.6.3",
7273
"jest-watch-typeahead": "^0.6.1",
7374
"lint-staged": "^10.0.10",
75+
"patch-package": "^6.4.7",
7476
"postcss": "^8.2.12",
7577
"postcss-preset-env": "^6.7.0",
78+
"postinstall-postinstall": "^2.1.0",
7679
"prettier": "^2.0.2",
7780
"tailwindcss": "^2.1.2",
7881
"twin.macro": "^2.4.0",
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff --git a/node_modules/@project-serum/anchor/dist/esm/program/common.js b/node_modules/@project-serum/anchor/dist/esm/program/common.js
2+
index 164d8ff..bab8614 100644
3+
--- a/node_modules/@project-serum/anchor/dist/esm/program/common.js
4+
+++ b/node_modules/@project-serum/anchor/dist/esm/program/common.js
5+
@@ -38,15 +38,6 @@ export function validateAccounts(ixAccounts, accounts = {}) {
6+
}
7+
// Translates an address to a Pubkey.
8+
export function translateAddress(address) {
9+
- if (typeof address === "string") {
10+
- const pk = new PublicKey(address);
11+
- return pk;
12+
- }
13+
- else if (address.constructor.prototype.constructor.name === "PublicKey") {
14+
- return address;
15+
- }
16+
- else {
17+
- throw new Error("Given address is not a PublicKey nor a string.");
18+
- }
19+
+ return new PublicKey(address);
20+
}
21+
//# sourceMappingURL=common.js.map
22+
\ No newline at end of file
23+
diff --git a/node_modules/@project-serum/anchor/src/program/common.ts b/node_modules/@project-serum/anchor/src/program/common.ts
24+
index 5fd24e1..4990e3d 100644
25+
--- a/node_modules/@project-serum/anchor/src/program/common.ts
26+
+++ b/node_modules/@project-serum/anchor/src/program/common.ts
27+
@@ -55,14 +55,7 @@ export function validateAccounts(
28+
29+
// Translates an address to a Pubkey.
30+
export function translateAddress(address: Address): PublicKey {
31+
- if (typeof address === "string") {
32+
- const pk = new PublicKey(address);
33+
- return pk;
34+
- } else if (address.constructor.prototype.constructor.name === "PublicKey") {
35+
- return address;
36+
- } else {
37+
- throw new Error("Given address is not a PublicKey nor a string.");
38+
- }
39+
+ return new PublicKey(address);
40+
}
41+
42+
/**

0 commit comments

Comments
 (0)