Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 71e9818

Browse files
build(deps): bump borsh from 0.7.0 to 2.0.0 (#5890)
* build(deps): bump borsh from 0.7.0 to 2.0.0 Bumps [borsh](https://github.com/near/borsh-js) from 0.7.0 to 2.0.0. - [Release notes](https://github.com/near/borsh-js/releases) - [Commits](near/borsh-js@v0.7.0...v2.0.0) --- updated-dependencies: - dependency-name: borsh dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * Fix for new borsh version --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jon Cinque <[email protected]>
1 parent eeb1ca9 commit 71e9818

File tree

5 files changed

+35
-50
lines changed

5 files changed

+35
-50
lines changed

account-compression/sdk/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"@metaplex-foundation/beet": "^0.7.1",
5858
"@metaplex-foundation/beet-solana": "^0.4.0",
5959
"bn.js": "^5.2.1",
60-
"borsh": "^0.7.0",
6160
"js-sha3": "^0.9.2",
6261
"typescript-collections": "^1.3.3"
6362
},

name-service/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"dependencies": {
6060
"@solana/web3.js": "^1.87.6",
6161
"bn.js": "^5.1.3",
62-
"borsh": "^0.7.0"
62+
"borsh": "^2.0.0"
6363
},
6464
"mocha": {
6565
"require": [

name-service/js/src/state.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { Connection, PublicKey } from '@solana/web3.js';
2-
import { deserializeUnchecked, Schema } from 'borsh';
2+
import { deserialize, Schema } from 'borsh';
3+
4+
type InitArgs = {
5+
parentName: Uint8Array;
6+
owner: Uint8Array;
7+
class: Uint8Array;
8+
};
39

410
export class NameRegistryState {
511
static HEADER_LEN = 96;
@@ -8,24 +14,14 @@ export class NameRegistryState {
814
class: PublicKey;
915
data: Buffer | undefined;
1016

11-
static schema: Schema = new Map([
12-
[
13-
NameRegistryState,
14-
{
15-
kind: 'struct',
16-
fields: [
17-
['parentName', [32]],
18-
['owner', [32]],
19-
['class', [32]],
20-
],
21-
},
22-
],
23-
]);
24-
constructor(obj: {
25-
parentName: Uint8Array;
26-
owner: Uint8Array;
27-
class: Uint8Array;
28-
}) {
17+
static schema: Schema = {
18+
struct: {
19+
parentName: { array: { type: 'u8', len: 32 } },
20+
owner: { array: { type: 'u8', len: 32 } },
21+
class: { array: { type: 'u8', len: 32 } },
22+
},
23+
};
24+
constructor(obj: InitArgs) {
2925
this.parentName = new PublicKey(obj.parentName);
3026
this.owner = new PublicKey(obj.owner);
3127
this.class = new PublicKey(obj.class);
@@ -43,11 +39,8 @@ export class NameRegistryState {
4339
throw new Error('Invalid name account provided');
4440
}
4541

46-
const res: NameRegistryState = deserializeUnchecked(
47-
this.schema,
48-
NameRegistryState,
49-
nameAccount.data,
50-
);
42+
const deserialized = deserialize(this.schema, nameAccount.data) as InitArgs;
43+
const res = new NameRegistryState(deserialized);
5144

5245
res.data = nameAccount.data?.slice(this.HEADER_LEN);
5346

name-service/js/src/twitter.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
SystemProgram,
55
TransactionInstruction,
66
} from '@solana/web3.js';
7-
import { deserialize, deserializeUnchecked, Schema, serialize } from 'borsh';
7+
import { deserialize, Schema, serialize } from 'borsh';
88

99
import { deleteNameRegistry, NAME_PROGRAM_ID } from './bindings';
1010
import {
@@ -291,11 +291,10 @@ export async function getTwitterHandleandRegistryKeyViaFilters(
291291
for (const f of filteredAccounts) {
292292
if (f.accountInfo.data.length > NameRegistryState.HEADER_LEN + 32) {
293293
const data = f.accountInfo.data.slice(NameRegistryState.HEADER_LEN);
294-
const state: ReverseTwitterRegistryState = deserialize(
294+
const state = deserialize(
295295
ReverseTwitterRegistryState.schema,
296-
ReverseTwitterRegistryState,
297296
data,
298-
);
297+
) as ReverseTwitterRegistryState;
299298
return [state.twitterHandle, new PublicKey(state.twitterRegistryKey)];
300299
}
301300
}
@@ -351,18 +350,12 @@ export class ReverseTwitterRegistryState {
351350
twitterRegistryKey: Uint8Array;
352351
twitterHandle: string;
353352

354-
static schema: Schema = new Map([
355-
[
356-
ReverseTwitterRegistryState,
357-
{
358-
kind: 'struct',
359-
fields: [
360-
['twitterRegistryKey', [32]],
361-
['twitterHandle', 'string'],
362-
],
363-
},
364-
],
365-
]);
353+
static schema: Schema = {
354+
struct: {
355+
twitterRegistryKey: { array: { type: 'u8', len: 32 } },
356+
twitterHandle: 'string',
357+
},
358+
};
366359
constructor(obj: { twitterRegistryKey: Uint8Array; twitterHandle: string }) {
367360
this.twitterRegistryKey = obj.twitterRegistryKey;
368361
this.twitterHandle = obj.twitterHandle;
@@ -380,11 +373,10 @@ export class ReverseTwitterRegistryState {
380373
throw new Error('Invalid reverse Twitter account provided');
381374
}
382375

383-
const res: ReverseTwitterRegistryState = deserializeUnchecked(
376+
const res = deserialize(
384377
this.schema,
385-
ReverseTwitterRegistryState,
386378
reverseTwitterAccount.data.slice(NameRegistryState.HEADER_LEN),
387-
);
379+
) as ReverseTwitterRegistryState;
388380

389381
return res;
390382
}

pnpm-lock.yaml

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)