diff --git a/app/components/account/AnchorAccountCard.tsx b/app/components/account/AnchorAccountCard.tsx index 2970e448..f3402266 100644 --- a/app/components/account/AnchorAccountCard.tsx +++ b/app/components/account/AnchorAccountCard.tsx @@ -1,6 +1,6 @@ import { ErrorCard } from '@components/common/ErrorCard'; -import { BorshAccountsCoder } from '@project-serum/anchor'; -import { IdlTypeDef } from '@project-serum/anchor/dist/cjs/idl'; +import { BorshAccountsCoder } from '@coral-xyz/anchor'; +import { IdlTypeDef } from '@coral-xyz/anchor/dist/cjs/idl'; import { Account } from '@providers/accounts'; import { useAnchorProgram } from '@providers/anchor'; import { useCluster } from '@providers/cluster'; diff --git a/app/components/instruction/AnchorDetailsCard.tsx b/app/components/instruction/AnchorDetailsCard.tsx index ebf34d07..a04e1e08 100644 --- a/app/components/instruction/AnchorDetailsCard.tsx +++ b/app/components/instruction/AnchorDetailsCard.tsx @@ -1,6 +1,6 @@ import { Address } from '@components/common/Address'; -import { BorshInstructionCoder, Idl, Instruction, Program } from '@project-serum/anchor'; -import { IdlInstruction } from '@project-serum/anchor/dist/cjs/idl'; +import { BorshInstructionCoder, Idl, Instruction, Program } from '@coral-xyz/anchor'; +import { IdlInstruction } from '@coral-xyz/anchor/dist/cjs/idl'; import { SignatureResult, TransactionInstruction } from '@solana/web3.js'; import { getAnchorAccountsFromInstruction, @@ -39,11 +39,11 @@ function AnchorDetails({ ix, anchorProgram }: { ix: TransactionInstruction; anch const { ixAccounts, decodedIxData, ixDef } = useMemo(() => { let ixAccounts: | { - name: string; - isMut: boolean; - isSigner: boolean; - pda?: object; - }[] + name: string; + isMut: boolean; + isSigner: boolean; + pda?: object; + }[] | null = null; let decodedIxData: Instruction | null = null; let ixDef: IdlInstruction | undefined; diff --git a/app/providers/anchor.tsx b/app/providers/anchor.tsx index 949b517e..43e13126 100644 --- a/app/providers/anchor.tsx +++ b/app/providers/anchor.tsx @@ -1,5 +1,5 @@ +import { AnchorProvider, Idl, Program, Wallet } from '@coral-xyz/anchor'; import { NodeWallet } from '@metaplex/js'; -import { Idl, Program, Provider } from '@project-serum/anchor'; import { Connection, Keypair } from '@solana/web3.js'; const cachedAnchorProgramPromises: Record< @@ -14,7 +14,7 @@ export function useAnchorProgram(programAddress: string, url: string): Program | if (cacheEntry === undefined) { const promise = Program.at( programAddress, - new Provider(new Connection(url), new NodeWallet(Keypair.generate()), {}) + new AnchorProvider(new Connection(url), new NodeWallet(Keypair.generate()) as Wallet, {}) ) .then(program => { cachedAnchorProgramPromises[key] = { diff --git a/app/utils/anchor.tsx b/app/utils/anchor.tsx index ecb692fb..d102c5b2 100644 --- a/app/utils/anchor.tsx +++ b/app/utils/anchor.tsx @@ -1,6 +1,6 @@ import { Address } from '@components/common/Address'; -import { BorshInstructionCoder, Idl, Program } from '@project-serum/anchor'; -import { IdlField, IdlInstruction, IdlType, IdlTypeDef } from '@project-serum/anchor/dist/cjs/idl'; +import { BorshInstructionCoder, Idl, Program } from '@coral-xyz/anchor'; +import { IdlField, IdlInstruction, IdlType, IdlTypeDef } from '@coral-xyz/anchor/dist/cjs/idl'; import { useAnchorProgram } from '@providers/anchor'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { Cluster } from '@utils/cluster'; @@ -54,11 +54,11 @@ export function getAnchorAccountsFromInstruction( program: Program ): | { - name: string; - isMut: boolean; - isSigner: boolean; - pda?: object; - }[] + name: string; + isMut: boolean; + isSigner: boolean; + pda?: object; + }[] | null { if (decodedIx) { // get ix accounts @@ -161,7 +161,9 @@ function mapField(key: string, value: any, type: IdlType, idl: Idl, keySuffix?: type === 'i64' || type === 'f64' || type === 'u128' || - type === 'i128' + type === 'i128' || + type === 'u256' || + type === 'i256' ) { return ( ); + } else if (fieldType?.type.kind === "alias") { + return mapField(fieldType.name, value, fieldType.type.value, idl, keySuffix, nestingLevel); } else { const enumVariantName = Object.keys(value)[0]; const variant = fieldType.type.variants.find( @@ -417,8 +421,8 @@ function typeDisplayName( type: | IdlType | { - enum: string; - } + enum: string; + } ): string { switch (type) { case 'bool': @@ -434,6 +438,8 @@ function typeDisplayName( case 'f64': case 'u128': case 'i128': + case 'u256': + case 'i256': case 'bytes': case 'string': return type.toString(); @@ -445,6 +451,6 @@ function typeDisplayName( if ('option' in type) return `${typeDisplayName(type.option)} (optional)`; if ('vec' in type) return `${typeDisplayName(type.vec)}[]`; if ('array' in type) return `${typeDisplayName(type.array[0])}[${type.array[1]}]`; - return 'unkonwn'; + return 'unknown'; } } diff --git a/package.json b/package.json index 885edf27..92963bf3 100644 --- a/package.json +++ b/package.json @@ -14,10 +14,10 @@ "@blockworks-foundation/mango-client": "^3.6.7", "@bonfida/spl-name-service": "0.1.30", "@cloudflare/stream-react": "^1.2.0", + "@coral-xyz/anchor": "^0.29.0", "@metamask/jazzicon": "^2.0.0", "@metaplex-foundation/mpl-token-metadata": "^1.1.0", "@metaplex/js": "^4.12.0", - "@project-serum/anchor": "^0.23.0", "@project-serum/serum": "^0.13.61", "@react-hook/debounce": "^4.0.0", "@react-hook/previous": "^1.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 634f994d..8860fb7b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ dependencies: '@cloudflare/stream-react': specifier: ^1.2.0 version: 1.2.0(react@18.2.0) + '@coral-xyz/anchor': + specifier: ^0.29.0 + version: 0.29.0 '@metamask/jazzicon': specifier: ^2.0.0 version: 2.0.0 @@ -29,9 +32,6 @@ dependencies: '@metaplex/js': specifier: ^4.12.0 version: 4.12.0(@metaplex-foundation/mpl-auction@0.0.2)(@metaplex-foundation/mpl-core@0.0.2)(@metaplex-foundation/mpl-metaplex@0.0.5)(@metaplex-foundation/mpl-token-metadata@1.1.0)(@metaplex-foundation/mpl-token-vault@0.0.2)(@solana/spl-token@0.1.8)(@solana/web3.js@1.66.0) - '@project-serum/anchor': - specifier: ^0.23.0 - version: 0.23.0 '@project-serum/serum': specifier: ^0.13.61 version: 0.13.61 @@ -1195,6 +1195,42 @@ packages: react: 18.2.0 dev: false + /@coral-xyz/anchor@0.29.0: + resolution: {integrity: sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA==} + engines: {node: '>=11'} + dependencies: + '@coral-xyz/borsh': 0.29.0(@solana/web3.js@1.78.0) + '@noble/hashes': 1.3.1 + '@solana/web3.js': 1.78.0 + bn.js: 5.2.1 + bs58: 4.0.1 + buffer-layout: 1.2.2 + camelcase: 6.3.0 + cross-fetch: 3.1.5 + crypto-hash: 1.3.0 + eventemitter3: 4.0.7 + pako: 2.1.0 + snake-case: 3.0.4 + superstruct: 0.15.5 + toml: 3.0.0 + transitivePeerDependencies: + - bufferutil + - encoding + - supports-color + - utf-8-validate + dev: false + + /@coral-xyz/borsh@0.29.0(@solana/web3.js@1.78.0): + resolution: {integrity: sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ==} + engines: {node: '>=10'} + peerDependencies: + '@solana/web3.js': ^1.68.0 + dependencies: + '@solana/web3.js': 1.78.0 + bn.js: 5.2.1 + buffer-layout: 1.2.2 + dev: false + /@emotion/babel-plugin@11.10.8: resolution: {integrity: sha512-gxNky50AJL3AlkbjvTARiwAqei6/tNUxDZPSKd+3jqWVM3AmdVTTdpjHorR/an/M0VJqdsuq5oGcFH+rjtyujQ==} dependencies: @@ -2447,31 +2483,6 @@ packages: - utf-8-validate dev: false - /@project-serum/anchor@0.23.0: - resolution: {integrity: sha512-LV2/ifZOJVFTZ4GbEloXln3iVfCvO1YM8i7BBCrUm4tehP7irMx4nr4/IabHWOzrQcQElsxSP/lb1tBp+2ff8A==} - engines: {node: '>=11'} - dependencies: - '@project-serum/borsh': 0.2.5(@solana/web3.js@1.66.0) - '@solana/web3.js': 1.66.0 - base64-js: 1.5.1 - bn.js: 5.2.1 - bs58: 4.0.1 - buffer-layout: 1.2.2 - camelcase: 5.3.1 - cross-fetch: 3.1.5 - crypto-hash: 1.3.0 - eventemitter3: 4.0.7 - find: 0.3.0 - js-sha256: 0.9.0 - pako: 2.1.0 - snake-case: 3.0.4 - toml: 3.0.0 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - /@project-serum/borsh@0.2.5(@solana/web3.js@1.66.0): resolution: {integrity: sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q==} engines: {node: '>=10'} @@ -4446,7 +4457,6 @@ packages: /camelcase@6.3.0: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} - dev: true /caniuse-lite@1.0.30001482: resolution: {integrity: sha512-F1ZInsg53cegyjroxLNW9DmrEQ1SuGRTO1QlpA0o2/6OpQ0gFeDRoq1yFmnr8Sakn9qwwt9DmbxHB6w167OSuQ==} @@ -8312,6 +8322,10 @@ packages: resolution: {integrity: sha512-wilec1Rg3FtKuRjRyCt70g5W29YUEuaLnybdVQUI+VQ7m0bw8k7TzrRv5iYmo6IpjLVrwxP5t3RgjAVqhYh4Fg==} dev: false + /superstruct@0.15.5: + resolution: {integrity: sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==} + dev: false + /supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} engines: {node: '>=4'}