name-service-js: Add to CI, clean up packages (#3097)

This commit is contained in:
Jon Cinque 2022-04-22 00:01:24 +02:00 committed by GitHub
parent f7d4ebecc6
commit b5e301b210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 2332 additions and 15708 deletions

View File

@ -56,3 +56,21 @@ jobs:
- name: Build and test - name: Build and test
run: ./ci/cargo-test-bpf.sh name-service run: ./ci/cargo-test-bpf.sh name-service
js-test:
runs-on: ubuntu-latest
env:
NODE_VERSION: 14.x
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.cache/yarn
key: node-${{ hashFiles('name-service/js/yarn.lock') }}
restore-keys: |
node-
- run: ./ci/js-test-name-service.sh

12
ci/js-test-name-service.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/.."
source ./ci/solana-version.sh install
set -x
cd name-service/js
yarn install --pure-lockfile
yarn lint
yarn build

File diff suppressed because it is too large Load Diff

View File

@ -21,10 +21,10 @@
"dev": "tsc && node --trace-warnings dist/transfer.js", "dev": "tsc && node --trace-warnings dist/transfer.js",
"build": "tsc", "build": "tsc",
"prepublish": "tsc", "prepublish": "tsc",
"lint": "yarn pretty && eslint .", "lint": "yarn pretty && eslint 'src/*.ts'",
"lint:fix": "yarn pretty:fix && eslint . --fix", "lint:fix": "yarn pretty:fix && eslint 'src/*.ts' --fix",
"pretty": "prettier --check 'src/*.[jt]s'", "pretty": "prettier --check 'src/*.ts'",
"pretty:fix": "prettier --write 'src/*.[jt]s'", "pretty:fix": "prettier --write 'src/*.ts'",
"doc": "yarn typedoc src/index.ts" "doc": "yarn typedoc src/index.ts"
}, },
"prettier": { "prettier": {
@ -32,7 +32,6 @@
}, },
"devDependencies": { "devDependencies": {
"@tsconfig/recommended": "^1.0.1", "@tsconfig/recommended": "^1.0.1",
"@types/bs58": "^4.0.1",
"@types/node": "^14.14.20", "@types/node": "^14.14.20",
"@typescript-eslint/eslint-plugin": "^4.0.1", "@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1", "@typescript-eslint/parser": "^4.0.1",
@ -42,26 +41,15 @@
"eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^3.0.2", "eslint-plugin-functional": "^3.0.2",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.22.0",
"nodemon": "^2.0.7",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"save-dev": "0.0.1-security",
"ts-node": "^9.1.1", "ts-node": "^9.1.1",
"tslib": "^2.2.0",
"typedoc": "^0.20.35", "typedoc": "^0.20.35",
"typescript": "^4.1.3" "typescript": "^4.1.3"
}, },
"dependencies": { "dependencies": {
"@solana/spl-token": "0.1.4", "@solana/spl-token": "0.1.4",
"@solana/web3.js": "^1.11.0", "@solana/web3.js": "^1.11.0",
"bip32": "^2.0.6",
"bn.js": "^5.1.3", "bn.js": "^5.1.3",
"borsh": "^0.4.0", "borsh": "^0.4.0"
"bs58": "4.0.1",
"core-util-is": "^1.0.2",
"crypto": "^1.0.1",
"crypto-ts": "^1.0.2",
"fs": "^0.0.1-security",
"tweetnacl": "^1.0.3",
"webpack-dev-server": "^3.11.2"
} }
} }

View File

@ -105,7 +105,7 @@ export function updateInstruction(
]; ];
const data = Buffer.concat(buffers); const data = Buffer.concat(buffers);
let keys = [ const keys = [
{ {
pubkey: nameAccountKey, pubkey: nameAccountKey,
isSigner: false, isSigner: false,
@ -139,7 +139,7 @@ export function transferInstruction(
newOwnerKey: PublicKey, newOwnerKey: PublicKey,
currentNameOwnerKey: PublicKey, currentNameOwnerKey: PublicKey,
nameClassKey?: PublicKey, nameClassKey?: PublicKey,
nameParent?:PublicKey nameParent?: PublicKey
): TransactionInstruction { ): TransactionInstruction {
const buffers = [Buffer.from(Int8Array.from([2])), newOwnerKey.toBuffer()]; const buffers = [Buffer.from(Int8Array.from([2])), newOwnerKey.toBuffer()];
@ -166,7 +166,7 @@ export function transferInstruction(
}); });
} }
if(nameParent){ if (nameParent) {
keys.push({ keys.push({
pubkey: nameParent, pubkey: nameParent,
isSigner: false, isSigner: false,

View File

@ -35,7 +35,7 @@ export class NameRegistryState {
connection: Connection, connection: Connection,
nameAccountKey: PublicKey nameAccountKey: PublicKey
): Promise<NameRegistryState> { ): Promise<NameRegistryState> {
let nameAccount = await connection.getAccountInfo( const nameAccount = await connection.getAccountInfo(
nameAccountKey, nameAccountKey,
'processed' 'processed'
); );
@ -43,7 +43,7 @@ export class NameRegistryState {
throw new Error('Invalid name account provided'); throw new Error('Invalid name account provided');
} }
let res: NameRegistryState = deserializeUnchecked( const res: NameRegistryState = deserializeUnchecked(
this.schema, this.schema,
NameRegistryState, NameRegistryState,
nameAccount.data nameAccount.data

View File

@ -4,6 +4,7 @@ import {
SystemProgram, SystemProgram,
TransactionInstruction, TransactionInstruction,
} from '@solana/web3.js'; } from '@solana/web3.js';
import { deserialize, deserializeUnchecked, Schema, serialize } from 'borsh';
import { deleteNameRegistry, NAME_PROGRAM_ID } from './bindings'; import { deleteNameRegistry, NAME_PROGRAM_ID } from './bindings';
import { import {
@ -20,7 +21,6 @@ import {
Numberu32, Numberu32,
Numberu64, Numberu64,
} from './utils'; } from './utils';
import { deserialize, deserializeUnchecked, Schema, serialize } from 'borsh';
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// Global Variables // Global Variables
@ -139,14 +139,6 @@ export async function changeVerifiedPubkey(
]; ];
// Delete the current reverse registry // Delete the current reverse registry
const currentHashedVerifiedPubkey = await getHashedName(
currentVerifiedPubkey.toString()
);
const currentReverseRegistryKey = await getNameAccountKey(
currentHashedVerifiedPubkey,
TWITTER_VERIFICATION_AUTHORITY,
undefined
);
instructions.push( instructions.push(
await deleteNameRegistry( await deleteNameRegistry(
connection, connection,
@ -254,7 +246,7 @@ export async function getHandleAndRegistryKey(
TWITTER_ROOT_PARENT_REGISTRY_KEY TWITTER_ROOT_PARENT_REGISTRY_KEY
); );
let reverseRegistryState = await ReverseTwitterRegistryState.retrieve( const reverseRegistryState = await ReverseTwitterRegistryState.retrieve(
connection, connection,
reverseRegistryKey reverseRegistryKey
); );
@ -298,8 +290,8 @@ export async function getTwitterHandleandRegistryKeyViaFilters(
for (const f of filteredAccounts) { for (const f of filteredAccounts) {
if (f.accountInfo.data.length > NameRegistryState.HEADER_LEN + 32) { if (f.accountInfo.data.length > NameRegistryState.HEADER_LEN + 32) {
let data = f.accountInfo.data.slice(NameRegistryState.HEADER_LEN); const data = f.accountInfo.data.slice(NameRegistryState.HEADER_LEN);
let state: ReverseTwitterRegistryState = deserialize( const state: ReverseTwitterRegistryState = deserialize(
ReverseTwitterRegistryState.schema, ReverseTwitterRegistryState.schema,
ReverseTwitterRegistryState, ReverseTwitterRegistryState,
data data
@ -380,7 +372,7 @@ export class ReverseTwitterRegistryState {
connection: Connection, connection: Connection,
reverseTwitterAccountKey: PublicKey reverseTwitterAccountKey: PublicKey
): Promise<ReverseTwitterRegistryState> { ): Promise<ReverseTwitterRegistryState> {
let reverseTwitterAccount = await connection.getAccountInfo( const reverseTwitterAccount = await connection.getAccountInfo(
reverseTwitterAccountKey, reverseTwitterAccountKey,
'processed' 'processed'
); );
@ -388,7 +380,7 @@ export class ReverseTwitterRegistryState {
throw new Error('Invalid reverse Twitter account provided'); throw new Error('Invalid reverse Twitter account provided');
} }
let res: ReverseTwitterRegistryState = deserializeUnchecked( const res: ReverseTwitterRegistryState = deserializeUnchecked(
this.schema, this.schema,
ReverseTwitterRegistryState, ReverseTwitterRegistryState,
reverseTwitterAccount.data.slice(NameRegistryState.HEADER_LEN) reverseTwitterAccount.data.slice(NameRegistryState.HEADER_LEN)
@ -412,7 +404,7 @@ export async function createReverseTwitterRegistry(
TWITTER_VERIFICATION_AUTHORITY, TWITTER_VERIFICATION_AUTHORITY,
TWITTER_ROOT_PARENT_REGISTRY_KEY TWITTER_ROOT_PARENT_REGISTRY_KEY
); );
let reverseTwitterRegistryStateBuff = serialize( const reverseTwitterRegistryStateBuff = serialize(
ReverseTwitterRegistryState.schema, ReverseTwitterRegistryState.schema,
new ReverseTwitterRegistryState({ new ReverseTwitterRegistryState({
twitterRegistryKey: twitterRegistryKey.toBytes(), twitterRegistryKey: twitterRegistryKey.toBytes(),

2285
name-service/js/yarn.lock Normal file

File diff suppressed because it is too large Load Diff