Skip to content

Commit

Permalink
Renaming and switching to straight bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Dec 9, 2023
1 parent d58698d commit 542444a
Show file tree
Hide file tree
Showing 75 changed files with 1,303 additions and 1,526 deletions.
2 changes: 1 addition & 1 deletion .github/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CARGO_TERM_COLOR=always
NODE_VERSION=16.x
PROGRAMS=["mpl-json"]
PROGRAMS=["mpl-inscription"]
RUST_VERSION=1.70.0
SOLANA_VERSION=1.16.18
6 changes: 3 additions & 3 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ program_common: &program_common
- ".github/file-filters.yml"
- ".github/.env"

mpl_json: &mpl_json
mpl_inscription: &mpl_inscription
- *program_common
- "programs/mpl-json/**"
- "programs/mpl-inscription/**"

programs: &programs
- *mpl_json
- *mpl_inscription

# Clients.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-rust-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ jobs:
with:
name: rust-client-builds
# First wildcard ensures exported paths are consistently under the clients folder.
path: ./client*/rust/target/release/*mpl_json*
path: ./client*/rust/target/release/*mpl_inscription*
if-no-files-found: error
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"rust-analyzer.linkedProjects": [
"./programs/mpl-json/Cargo.toml",
"./programs/mpl-inscription/Cargo.toml",
]
}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to Mpl Json
# Contributing to Mpl Inscription

This is a quick guide to help you contribute to Mpl Json.
This is a quick guide to help you contribute to Mpl Inscription.

## Getting started

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Mpl Json
# Mpl Inscription

A simple program for writing JSON bytes on chain.
A simple program for inscribing bytes on chain.

## Programs

This project contains the following programs:

- [Mpl Json](./programs/mpl-json/README.md) `JSoNoHBzUEFnjpZtcNcNzv5KLzo4tD5v4Z1pT9G4jJa`
- [Mpl Inscription](./programs/mpl-inscription/README.md) `JSoNoHBzUEFnjpZtcNcNzv5KLzo4tD5v4Z1pT9G4jJa`

You will need a Rust version compatible with BPF to compile the program, currently we recommend using Rust 1.68.0.

Expand Down
4 changes: 2 additions & 2 deletions clients/js/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to the JavaScript client

This is a quick guide to help you contribute to the JavaScript client of Mpl Json.
This is a quick guide to help you contribute to the JavaScript client of Mpl Inscription.

## Getting started

Expand Down Expand Up @@ -49,7 +49,7 @@ To publish JavaScript clients using GitHub actions, we first need the following
Then, we'll need to create a new GitHub environment called `js-client-documentation` for the generated documentation of the JavaScript client. We can then select the `main` branch only and add the following secret variable to this specific environment.

- `VERCEL_PROJECT_ID` — The ID of the Vercel project you want to deploy to.
The convention for Metaplex is to create a new Vercel project named `mpl-json-js-docs` with the following deployment settings:
The convention for Metaplex is to create a new Vercel project named `mpl-inscription-js-docs` with the following deployment settings:

- Build Command: `pnpm run build:docs`
- Output Directory: `docs`
Expand Down
10 changes: 5 additions & 5 deletions clients/js/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JavaScript client for Mpl Json
# JavaScript client for Mpl Inscription

A Umi-compatible JavaScript library for the project.

Expand All @@ -7,15 +7,15 @@ A Umi-compatible JavaScript library for the project.
1. First, if you're not already using Umi, [follow these instructions to install the Umi framework](https://github.com/metaplex-foundation/umi/blob/main/docs/installation.md).
2. Next, install this library using the package manager of your choice.
```sh
npm install @metaplex-foundation/mpl-json
npm install @metaplex-foundation/mpl-inscription
```
2. Finally, register the library with your Umi instance like so.
```ts
import { mplJson } from '@metaplex-foundation/mpl-json';
umi.use(mplJson());
import { MplInscription } from '@metaplex-foundation/mpl-inscription';
umi.use(MplInscription());
```

You can learn more about this library's API by reading its generated [TypeDoc documentation](https://mpl-json-js-docs.vercel.app).
You can learn more about this library's API by reading its generated [TypeDoc documentation](https://mpl-inscription-js-docs.vercel.app).

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions clients/js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@metaplex-foundation/mpl-json",
"name": "@metaplex-foundation/mpl-inscription",
"version": "0.1.0",
"description": "A simple program for writing JSON bytes on chain.",
"description": "A simple program for inscribing bytes on chain.",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* @see https://github.com/metaplex-foundation/kinobi
*/

export * from './jsonMetadata';
export * from './inscriptionMetadata';
201 changes: 201 additions & 0 deletions clients/js/src/generated/accounts/inscriptionMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/**
* This code was AUTOGENERATED using the kinobi library.
* Please DO NOT EDIT THIS FILE, instead use visitors
* to add features, then rerun kinobi to update it.
*
* @see https://github.com/metaplex-foundation/kinobi
*/

import {
Account,
Context,
Option,
OptionOrNullable,
Pda,
PublicKey,
RpcAccount,
RpcGetAccountOptions,
RpcGetAccountsOptions,
assertAccountExists,
deserializeAccount,
gpaBuilder,
publicKey as toPublicKey,
} from '@metaplex-foundation/umi';
import {
Serializer,
array,
option,
publicKey as publicKeySerializer,
string,
struct,
u64,
u8,
} from '@metaplex-foundation/umi/serializers';
import { Key, KeyArgs, getKeySerializer } from '../types';

export type InscriptionMetadata = Account<InscriptionMetadataAccountData>;

export type InscriptionMetadataAccountData = {
key: Key;
bump: number;
inscriptionNumber: Option<bigint>;
updateAuthorities: Array<PublicKey>;
};

export type InscriptionMetadataAccountDataArgs = {
key: KeyArgs;
bump: number;
inscriptionNumber: OptionOrNullable<number | bigint>;
updateAuthorities: Array<PublicKey>;
};

export function getInscriptionMetadataAccountDataSerializer(): Serializer<
InscriptionMetadataAccountDataArgs,
InscriptionMetadataAccountData
> {
return struct<InscriptionMetadataAccountData>(
[
['key', getKeySerializer()],
['bump', u8()],
['inscriptionNumber', option(u64())],
['updateAuthorities', array(publicKeySerializer())],
],
{ description: 'InscriptionMetadataAccountData' }
) as Serializer<
InscriptionMetadataAccountDataArgs,
InscriptionMetadataAccountData
>;
}

export function deserializeInscriptionMetadata(
rawAccount: RpcAccount
): InscriptionMetadata {
return deserializeAccount(
rawAccount,
getInscriptionMetadataAccountDataSerializer()
);
}

export async function fetchInscriptionMetadata(
context: Pick<Context, 'rpc'>,
publicKey: PublicKey | Pda,
options?: RpcGetAccountOptions
): Promise<InscriptionMetadata> {
const maybeAccount = await context.rpc.getAccount(
toPublicKey(publicKey, false),
options
);
assertAccountExists(maybeAccount, 'InscriptionMetadata');
return deserializeInscriptionMetadata(maybeAccount);
}

export async function safeFetchInscriptionMetadata(
context: Pick<Context, 'rpc'>,
publicKey: PublicKey | Pda,
options?: RpcGetAccountOptions
): Promise<InscriptionMetadata | null> {
const maybeAccount = await context.rpc.getAccount(
toPublicKey(publicKey, false),
options
);
return maybeAccount.exists
? deserializeInscriptionMetadata(maybeAccount)
: null;
}

export async function fetchAllInscriptionMetadata(
context: Pick<Context, 'rpc'>,
publicKeys: Array<PublicKey | Pda>,
options?: RpcGetAccountsOptions
): Promise<InscriptionMetadata[]> {
const maybeAccounts = await context.rpc.getAccounts(
publicKeys.map((key) => toPublicKey(key, false)),
options
);
return maybeAccounts.map((maybeAccount) => {
assertAccountExists(maybeAccount, 'InscriptionMetadata');
return deserializeInscriptionMetadata(maybeAccount);
});
}

export async function safeFetchAllInscriptionMetadata(
context: Pick<Context, 'rpc'>,
publicKeys: Array<PublicKey | Pda>,
options?: RpcGetAccountsOptions
): Promise<InscriptionMetadata[]> {
const maybeAccounts = await context.rpc.getAccounts(
publicKeys.map((key) => toPublicKey(key, false)),
options
);
return maybeAccounts
.filter((maybeAccount) => maybeAccount.exists)
.map((maybeAccount) =>
deserializeInscriptionMetadata(maybeAccount as RpcAccount)
);
}

export function getInscriptionMetadataGpaBuilder(
context: Pick<Context, 'rpc' | 'programs'>
) {
const programId = context.programs.getPublicKey(
'mplInscription',
'JSoNoHBzUEFnjpZtcNcNzv5KLzo4tD5v4Z1pT9G4jJa'
);
return gpaBuilder(context, programId)
.registerFields<{
key: KeyArgs;
bump: number;
inscriptionNumber: OptionOrNullable<number | bigint>;
updateAuthorities: Array<PublicKey>;
}>({
key: [0, getKeySerializer()],
bump: [1, u8()],
inscriptionNumber: [2, option(u64())],
updateAuthorities: [null, array(publicKeySerializer())],
})
.deserializeUsing<InscriptionMetadata>((account) =>
deserializeInscriptionMetadata(account)
);
}

export function findInscriptionMetadataPda(
context: Pick<Context, 'eddsa' | 'programs'>,
seeds: {
/** The address of the Inscription Account */
inscriptionAccount: PublicKey;
}
): Pda {
const programId = context.programs.getPublicKey(
'mplInscription',
'JSoNoHBzUEFnjpZtcNcNzv5KLzo4tD5v4Z1pT9G4jJa'
);
return context.eddsa.findPda(programId, [
string({ size: 'variable' }).serialize('Inscription'),
publicKeySerializer().serialize(programId),
publicKeySerializer().serialize(seeds.inscriptionAccount),
]);
}

export async function fetchInscriptionMetadataFromSeeds(
context: Pick<Context, 'eddsa' | 'programs' | 'rpc'>,
seeds: Parameters<typeof findInscriptionMetadataPda>[1],
options?: RpcGetAccountOptions
): Promise<InscriptionMetadata> {
return fetchInscriptionMetadata(
context,
findInscriptionMetadataPda(context, seeds),
options
);
}

export async function safeFetchInscriptionMetadataFromSeeds(
context: Pick<Context, 'eddsa' | 'programs' | 'rpc'>,
seeds: Parameters<typeof findInscriptionMetadataPda>[1],
options?: RpcGetAccountOptions
): Promise<InscriptionMetadata | null> {
return safeFetchInscriptionMetadata(
context,
findInscriptionMetadataPda(context, seeds),
options
);
}
Loading

0 comments on commit 542444a

Please sign in to comment.