Skip to content

Commit

Permalink
fix @project-serum/anchor publickey issue
Browse files Browse the repository at this point in the history
to remove after coral-xyz/anchor#1138 is
merged
  • Loading branch information
0xCryptoSheik committed Dec 13, 2021
1 parent 7c3a9bc commit b478ebd
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 83 deletions.
7 changes: 7 additions & 0 deletions next.config.js
Expand Up @@ -5,6 +5,13 @@ const withTM = require('next-transpile-modules')(['react-markdown'])
module.exports = withTM({
target: 'serverless',
webpack: (config, { isServer }) => {
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
'@project-serum/anchor$': '@project-serum/anchor/dist/esm',
},
}
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
Expand Down
11 changes: 7 additions & 4 deletions package.json
Expand Up @@ -14,7 +14,8 @@
"lint": "eslint . --ext ts --ext tsx --ext js --ext jsx",
"test": "jest",
"test-all": "yarn lint && yarn type-check && yarn test",
"notifier": "TS_NODE_PROJECT=./tsconfig.commonjs.json ts-node scripts/governance-notifier.ts"
"notifier": "TS_NODE_PROJECT=./tsconfig.commonjs.json ts-node scripts/governance-notifier.ts",
"postinstall": "patch-package"
},
"lint-staged": {
"*.@(ts|tsx|js|jsx)": [
Expand All @@ -23,16 +24,16 @@
},
"dependencies": {
"@blockworks-foundation/mango-client": "^3.2.15",
"@project-serum/anchor": "^0.19.0",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "1.31.0",
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.3.0",
"@headlessui/react": "^1.0.0",
"@heroicons/react": "^1.0.1",
"@project-serum/anchor": "^0.19.0",
"@project-serum/borsh": "^0.2.2",
"@project-serum/common": "^0.0.1-beta.3",
"@project-serum/sol-wallet-adapter": "^0.2.0",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "1.31.0",
"@tippyjs/react": "^4.2.5",
"@uxdprotocol/uxd-client": "^2.56.0",
"axios": "^0.21.1",
Expand Down Expand Up @@ -71,8 +72,10 @@
"jest": "^26.6.3",
"jest-watch-typeahead": "^0.6.1",
"lint-staged": "^10.0.10",
"patch-package": "^6.4.7",
"postcss": "^8.2.12",
"postcss-preset-env": "^6.7.0",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.0.2",
"tailwindcss": "^2.1.2",
"twin.macro": "^2.4.0",
Expand Down
20 changes: 20 additions & 0 deletions patches/@project-serum+anchor+0.19.0.patch
@@ -0,0 +1,20 @@
diff --git a/node_modules/@project-serum/anchor/src/program/common.ts b/node_modules/@project-serum/anchor/src/program/common.ts
index 5fd24e1..4990e3d 100644
--- a/node_modules/@project-serum/anchor/src/program/common.ts
+++ b/node_modules/@project-serum/anchor/src/program/common.ts
@@ -55,14 +55,7 @@ export function validateAccounts(

// Translates an address to a Pubkey.
export function translateAddress(address: Address): PublicKey {
- if (typeof address === "string") {
- const pk = new PublicKey(address);
- return pk;
- } else if (address.constructor.prototype.constructor.name === "PublicKey") {
- return address;
- } else {
- throw new Error("Given address is not a PublicKey nor a string.");
- }
+ return new PublicKey(address);
}

/**

0 comments on commit b478ebd

Please sign in to comment.